- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to port a Fortran code from Windows to Linux. It was compiled using the Windows Fortran compiler. I am using the Intel Linux Fortran compiler. There is a construct used in the code that apparently has been deprecated and is no longer valid Fortran. The Intel compiler does not let it go through (as it should not) and I need to find the way to do it using current Fortran practices. The original code looks like this:
npred=SIZE(xpred1,dim=1)
10 FORMAT(1x,e16.8)
WRITE(1,10) (((peta_xtheta(ii,i,j),ii=1,npred),i=1,idim),j=1,len_pvals)
Basically, the format statement depends on the value of the integer "npred". I came up with something in the internet that looks like this:
CHARACTER*80 FMT
...
npred=SIZE(xpred1,dim=1)
WRITE(FMT,((1x,,I0,e16.8))) npred
WRITE(1,FMT) (((peta_xtheta(ii,i,j),ii=1,npred),i=1,idim), j=1,len_pvals)
However, that does not seems to work. Here is the error message from the Intel Compiler:
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
--------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '(?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
---------------------^
gpred_vcf_nocal.f90(207): error #5143: Missing mandatory separating blank
WRITE(FMT,((1x,,I0,e16.8))) npred
-------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
---------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
--------------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
---------------------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
-----------------------------------------^
gpred_vcf_nocal.f90(207): error #5276: Unbalanced parentheses
WRITE(FMT,((1x,,I0,e16.8))) npred
------------------------------------------^
gpred_vcf_nocal.f90(207): error #5082: Syntax error, found IDENTIFIER 'X' when expecting one of: * ) :: , ; + . - (/ [ : ] /) ' ** / // > .LT. ...
WRITE(FMT,((1x,,I0,e16.8))) npred
-------------------------^
compilation aborted for gpred_vcf_nocal.f90 (code 1)
make: *** [gpred_vcf_nocal.o] Error 1
If anyone can help, it would be appreciated. Thanks,
Noel
I am trying to port a Fortran code from Windows to Linux. It was compiled using the Windows Fortran compiler. I am using the Intel Linux Fortran compiler. There is a construct used in the code that apparently has been deprecated and is no longer valid Fortran. The Intel compiler does not let it go through (as it should not) and I need to find the way to do it using current Fortran practices. The original code looks like this:
npred=SIZE(xpred1,dim=1)
10 FORMAT(1x,
WRITE(1,10) (((peta_xtheta(ii,i,j),ii=1,npred),i=1,idim),j=1,len_pvals)
Basically, the format statement depends on the value of the integer "npred". I came up with something in the internet that looks like this:
CHARACTER*80 FMT
...
npred=SIZE(xpred1,dim=1)
WRITE(FMT,((1x,,I0,e16.8))) npred
WRITE(1,FMT) (((peta_xtheta(ii,i,j),ii=1,npred),i=1,idim), j=1,len_pvals)
However, that does not seems to work. Here is the error message from the Intel Compiler:
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
--------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '(?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
---------------------^
gpred_vcf_nocal.f90(207): error #5143: Missing mandatory separating blank
WRITE(FMT,((1x,,I0,e16.8))) npred
-------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
---------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
--------------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
---------------------------------------^
gpred_vcf_nocal.f90(207): error #5078: Unrecognized token '?' skipped
WRITE(FMT,((1x,,I0,e16.8))) npred
-----------------------------------------^
gpred_vcf_nocal.f90(207): error #5276: Unbalanced parentheses
WRITE(FMT,((1x,,I0,e16.8))) npred
------------------------------------------^
gpred_vcf_nocal.f90(207): error #5082: Syntax error, found IDENTIFIER 'X' when expecting one of: * ) :: ,
WRITE(FMT,((1x,,I0,e16.8))) npred
-------------------------^
compilation aborted for gpred_vcf_nocal.f90 (code 1)
make: *** [gpred_vcf_nocal.o] Error 1
If anyone can help, it would be appreciated. Thanks,
Noel
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The variable format things were never valid fortran. That said, I'm a little surprised that the linux variant of the fortran compiler doesn't accept that particular extension - the extension is described in the docs that come with the linux compiler.
But what you are proposing to do instead is a far better way to go anyway.
You are almost there - the problem is that the example you've cut and pasted is using quote characters that are not the ones that are typically generated in an editor when you hit the ' and " keys on your keyboard - probably because of an attempt by a browser or web server to format the example to make it look nicer (or perhaps the source code has gone via a word processor). The compiler doesn't recognize these strange quotes - hence the plethora of errors.
Go through the code and replace by " and by '. Be mindful that there may be some other characters that have come across that are not just the boring "ascii" characters that typically comprise source code and that sometimes editors will change the encoding of a file when they encounter such characters.
But what you are proposing to do instead is a far better way to go anyway.
You are almost there - the problem is that the example you've cut and pasted is using quote characters that are not the ones that are typically generated in an editor when you hit the ' and " keys on your keyboard - probably because of an attempt by a browser or web server to format the example to make it look nicer (or perhaps the source code has gone via a word processor). The compiler doesn't recognize these strange quotes - hence the plethora of errors.
Go through the code and replace by " and by '. Be mindful that there may be some other characters that have come across that are not just the boring "ascii" characters that typically comprise source code and that sometimes editors will change the encoding of a file when they encounter such characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran for Linux certainly does support the VFE extension. After all, we created it back in the DEC days. If you have a test case, and not just a fragment, please post it and include the error messages.
[plain][sblionel@f90srv34 ~/project]$ cat t.f90 integer :: a(4) = [1,2,3,4] n = size(a) print 101, a 101 format(I5) end [sblionel@f90srv34 ~/project]$ ifort t.f90 [sblionel@f90srv34 ~/project]$ ./a.out 1 2 3 4 [sblionel@f90srv34 ~/project]$ [/plain]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried this once and it worked fine, but apparently it takes a lot of code as the size of my program grew to much, so I avoid it now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program VARFORMAT
INTEGER II,I,J
REAL*8 PETA_XTHETA(3,3,3)
CHARACTER*8 FMT(3)
! divide the format into 8-character sections...
DATA FMT/8H(10X, ,8H ,8HE16.8) / ! Blanks are used to fill remaining character spaces
peta_xtheta=9
IDIM=3
len_pvals=3
NPRED=3
WRITE(FMT(2),'(I8)') NPRED
WRITE(6,'(''FMT= '',3A8)') FMT
WRITE(6,FMT) (((peta_xtheta(ii,i,j),ii=1,npred),i=1,idim), j=1,len_pvals)
PAUSE
end program VARFORMAT
OUTPUT:
FMT= (10X, 3E16.8)
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
Fortran Pause - Enter command
Alternatively:
program varformat2
INTEGER II,I,J
REAL*8 PETA_XTHETA(3,3,3)
CHARACTER*8 FSTART, FMIDDLE, FEND
CHARACTER*24 FMT
FSTART="(10X,"
FMIDDLE=" "
FEND="E16.8)"
peta_xtheta=9
NPRED=3
IDIM=3
len_pvals=3
WRITE(FMIDDLE,'(I8)') NPRED
FMT=FSTART//FMIDDLE//FEND
WRITE(6,'(''FMT= '',A24)') FMT
WRITE(6,FMT) (((peta_xtheta(ii,i,j),ii=1,npred),i=1,idim), j=1,len_pvals)
PAUSE
end program varformat2
OUTPUT:
FMT= (10X, 3E16.8)
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
0.90000000E+01 0.90000000E+01 0.90000000E+01
Fortran Pause - Enter command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All,
I was wrong, the Intel Linux compiler does indeed support the <> construct. I decided to change the code nonetheless to the way I was trying first. The problem was that the quotes used were not the standard ones. After I switched them like "IanH" kindly suggested, the compiler errors were gone. Thanks for the replies everyone.
Noel

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