- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Lionel and Macej, thanks for the prompt resp. I have attached the .f for your review.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The attachment is not there. Please try again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Error 1 error #6218: This statement is positioned incorrectly and/or has syntax errors. C:\Working\Q698DalMigration\Q698DalMigration\Q698DalMigration\maxmo.f90 16
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, did as you suggested but still no luck. Should I just add the original maxmo.f into the source and build the project?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That would probably work. Perhaps you altered the spacing when pasting it in to the .f90.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am about to have similar problems so can you tell us how it went?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page