jmeubank / tdm-gcc

TDM-GCC is a cleverly disguised GCC compiler for Windows!
https://jmeubank.github.io/tdm-gcc/
584 stars 49 forks source link

Loading an existing class array in the constructor #72

Open yu88ktym opened 2 months ago

yu88ktym commented 2 months ago

Hello, I am trying to compile and run an f90 program with gfortran. I am currently compiling and executing an f90 program using gfortran. However, when I actually try to compile it, I get the error shown at the bottom. This error does not appear if I do not define a constructor for PolygonalChain.

The actual class usage example is shown in main.f90, for example, I want to use it as follows. In this program, the distance is calculated after defining Polygonal Chain on the earth.

Reference: https://en.wikipedia.org/wiki/Polygonal_chain

program main
use cls_polygonal_chain, only: PolygonalChain
...
type(PolygonalChain) :: poly_chain 
poly_chain = PolygonalChain(pos, N) 
call poly_chain%cal_distance(distance2, earth_radius, .True.)
...
end program

The program will fail to compile in the state we are sending you, but we are sending it to you as an ideal form. How should I write the program to work correctly in such a case?

PS F:\IT\research\experiment\fortran_objective_programming> gfortran --version
GNU Fortran (tdm64-1) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

PS F:\IT\research\experiment\fortran_objective_programming> gfortran mod_param.f90 cls_position.f90 cls_polygonal_chain.f90 main.f90
during RTL pass: expand
cls_polygonal_chain.f90:27:40:

   27 |     subroutine set_chain(self, pos_array, n)
      |                                        ^
internal compiler error: in expand_expr_real_1, at expr.c:10132
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://github.com/jmeubank/tdm-gcc/issues> for instructions.

edition Windows 11 Pro version 23H2 install date ‎2023/‎05/‎31 OS build 22631.4037 experience Windows Feature Experience Pack 1000.22700.1027.0

fortran_objective_programming.zip