Question

I would like to use some light scattering codes written in Fortran. I am quite familiar with MATLAB and teaching myself C++ but right now Fortran is causing me a lot of grief.

I just got Photran working with Eclipse and it works compiling (using Gfortran from Cygwin as per Photrans instructions) example Fortran programs I have found online.

The main one I would like to get working is here: http://www.ugr.es/~aquiran/ciencia/codigos/homer.f (note over half of it is just console output and comments it seems, the actual code is quite small).

I actually have written a program in Mathematica which do these calculations already, but I feel it would be a good test case to get my hands dirty in Fortran and move to other codes. If anyone could point me in the right direction to get this compiling that would be great. Thanks.

Edit: So I get it as far as compiling it with just up to (just with warnings)

OPEN (1,FILE='q.dat')

The second I add

DO I=1,5
    WRITE (*,*)
END DO

I get 3 errors:

Fortran errors

Once I remove the DO I can add the writing and eg.

    WRITE (*,*) 'This code calculates cross-efficiencies for'

And it will compile and make the .exe. I am guessing the DO's are causing me a issue.

Was it helpful?

Solution

Turns out I needed the

gfortran -ffixed-line-length-n 

flag, with n as 132 for the source code I linked. I had some other code that does a similar calculation working and it lined up perfectly in Eclipse's guide lines, but this one was way out. Thanks for getting me on the right track guys.

OTHER TIPS

This is simpler solution. Your code is fixed format,i.e.,so the maximum length of code line in the source is 72. You just need to put "extra" code in the new line. It is shown below(line continuation with . at column 6)

C        1         2         3         4         5         6         7
C23456789012345678901234567890123456789012345678901234567890123456789012
      WRITE (*,*) '(For a single particle size, make it equal to the min 
     .imum value)'
      READ (*,*) kr2 
C Just in case Homer cannot handle it...
      IF((KR+4.0D0*KR**0.33333+2).gt.MSIZE) THEN
      WRITE (*,*) 'Sorry, this value is too high'
      WRITE (*,*) 'Please enter a value smaller than', int(msize-4.0D0*m
     .size**0.33333+2)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top