Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28996 Discussions

Migrating fortran .f to Intel Visual Fortran and functions

Sazid_P_
Beginner
1,387 Views

Hi, I would like to know if there is a guide to migrating fortran code running on linux to windows, also have basically migrated with a lttle pain but having issues with a .f which contains a function. The code does not compile and throws error

Error 1  error #6218: This statement is positioned incorrectly and/or has syntax errors
Any help wil be greatly appreciated.

Thanks

0 Kudos
12 Replies
Steven_L_Intel1
Employee
1,387 Views

You will need to show us the code. Typically no "migration" is needed unless you are making use of Linux-only libraries or making assumptions about external procedure naming. The error you show suggests that you have some malformed source, or perhaps you have free-form source incorrectly named as a .f file instead of .f90.

Please attach the source in question (or post the lines of code it complained about, with some context) so we can see.

0 Kudos
mecej4
Honored Contributor III
1,387 Views

Sazid:

The so called migration problems probably relate more to migrating to a different compiler than to a different operating system. Which compiler did you use on Linux?

When the error is about syntax errors and incorrect positioning, it should be obvious to you that you should attach the code or provide at least the relevant portions of it. Were that unnecessary, and a universal cure available for this type of error, you would probably not see such an error message at all.

 

0 Kudos
Sazid_P_
Beginner
1,387 Views

Hey Lionel and Macej, thanks for the prompt resp. I have attached the .f for your review.

Thanks

0 Kudos
Steven_L_Intel1
Employee
1,387 Views

The attachment is not there. Please try again.

0 Kudos
Sazid_P_
Beginner
1,387 Views

copied in the code belw and also tried attaching again..hopefully it has attached. Thanks

 

 

integer*2 function maxmo(mm,yyyy,i2code)

integer*2 mm,yyyy,i2code

i2code = 0

maxmo = 0

if(yyyy.lt.1900.or.yyyy.gt.2500)then

i2code = 1

write(*,*)'maxmo Invalid year passed in ... ',yyyy

return

endif

if(mm.eq.1.or.mm.eq.3.or.mm.eq.5.or.

+ mm.eq.7.or.mm.eq.8.or.mm.eq.10.or.

+ mm.eq.12)then

maxmo = 31

else if(mm.eq.2)then

if(mod(yyyy,4).eq.0)then

maxmo = 29

if(mod(yyyy,100).eq.0.and.mod(yyyy,400).ne.0)then

maxmo = 28

endif

else

maxmo = 28

endif

else if(mm.eq.4.or.mm.eq.6.or.mm.eq.9.or.mm.eq.11)then

maxmo = 30

else

i2code = 1

write(*,*)'Invalid month passed in ... ',mm

return

endif

 

return

end

0 Kudos
TimP
Honored Contributor III
1,387 Views

After appending & as required to the continued source lines, ifort has no complaints (unless -stand is set), but gfortran can be made to warn that the constants are default integer, thus inconsistent with your non-standard integer*2 data type even without setting standards warning.

So it looks like the main complaint may be about your source code formatting.  I can't imagine which linux Fortran would accept it as is.

0 Kudos
Steven_L_Intel1
Employee
1,387 Views

I see no errors when compiling this code. Please show us the actual and complete error message.

Tim, this is fixed-form source. The leading blanks get removed when just pasted into the forum here. It compiles fine when properly spaced as fixed-form. My guess is that the source was pasted into a .f90 file.

0 Kudos
Sazid_P_
Beginner
1,387 Views

Error 1  error #6218: This statement is positioned incorrectly and/or has syntax errors. C:\Working\Q698DalMigration\Q698DalMigration\Q698DalMigration\maxmo.f90 16 
 

0 Kudos
Steven_L_Intel1
Employee
1,387 Views

Yep - that's what you did. You created a new free-form source file with a .f90 file type and then pasted fixed-form source into it. Rename the source file to maxmo.f and it should work ok.

See also https://software.intel.com/en-us/blogs/2013/01/11/doctor-fortran-in-source-form-just-wants-to-be-free

0 Kudos
Sazid_P_
Beginner
1,387 Views

Steve, did as you suggested but still no luck. Should I just add the original maxmo.f into the source and build the project?

0 Kudos
Steven_L_Intel1
Employee
1,387 Views

That would probably work. Perhaps you altered the spacing when pasting it in to the .f90.

0 Kudos
RedSonja57
Beginner
1,387 Views

I am about to have similar problems so can you tell us how it went?

0 Kudos
Reply