Error creating text files on Fortran and CUDA Fortran

Hello!

I have PGI Visual Fortran 2010 (11.3), on Windows 7 64-Bit. I’m using the 32-bit command shell, because on the 64-bit version I got errors like (after a successfully compilation)

filename.obj : error LNK2001: unresolved external symbols .STATICS2
filename.exe : fatal error LNK1120: 1 unresolved externals

I don’t know why it happens, buy actually I can run CUDA Fortran code on 32 Bit command shell.


Ok my question is about two versions of the same program: Fortran and CUDA Fortran, both of them read a text file from disk and save results on 3 text files, the programs should to get the same results and I use MATLAB for result’s comparison (visual and numerical) the variables on the text files are matrices, their sizes depends of 2 integer parameters (mc and wfl) like this:

! 8000/wfl is always and integer
REAL, DIMENSION(8000/wfl,mc) :: cracks, ratiok, POF

The weird problem is, the number of columns depends of mc and in the Fortran version I ALWAYS got 3 columns, the rows number get increase and the product is always the same, for example:

wfl=10 and mc=90
cracks SHOULD BE: (800,90)
I got when import the text file to MATLAB: (24000,3)

I compile the Fortran code with gfortran on linux and the text files have ALWAYS the correct size

In CUDA Fortran is similar the situation, using wfl=10 and mc=32, the table should be (800,32) instead of that I got (6400,4). Always 4 columns!

In both cases (Fortran and CUDA Fortran) the total number of elements is always the same (8000/wfl)*mc


I don’t know what’s wrong, why is this happening? I need the correct sizes on text files to keep working on MATLAB, please help.

Thanks

Hi Maomerino,

My best guess is that it’s a newline problem. Newline is represented differently on Windows and Linux. To test my theory, please move your Windows generated text to a Linux system and load the file into Matlab. Do the same error occur? If so, run the ‘dos2unix’ on your text file and then re-load into Matlab. Did that fix the problem?

  • Mat

Hello Mat! and thanks for your help.

Unfortunately it didn’t work, I just can try with the Fortran file because I don’t have a CUDA Fortran compiler on the Linux machine…

So, the text file was generated with pgfortran on the 32-Bit command shell (PVF 11.3), using Windows 7 64-Bit, I checked the file with MATLAB 64-bit and, as always I got 3 columns.

I took the text file and went to Linux (Ubuntu, 32-Bit), then, I imported the text file on MATLAB (for Unix, 32 Bits) it has the same 3 columns, but I took the .f90 file and compiled, linked and ran on Linux with gfortran, the generated files have the correct size in Linux (MATLAB 32-Bit) and Windows 7 (MATLAB 64-bit)

So, I don’t Understand what’s happening… thanks for your help.

I took the text file and went to Linux (Ubuntu, 32-Bit), then, I imported the text file on MATLAB (for Unix, 32 Bits) it has the same 3 columns

Now what happens if you run the ‘dos2unix’ on the text file?

  • Mat

No, I used dos2unix on the file:

dos2unix: converting file cra.txt to UNIX format …


But nothing changed, the file still have the 3 columns both MATLAB Linux and Windows

Hi Maomerino,

The next step would be to check your format. Are you using list directed output or an explicit format specification? For list directed, the format produced is not standard across compilers. Hence, you should use explicit formatting if you need a specific format.

If this isn’t the problem either, then I’ll need a reproducing example.

Thanks,
Mat

I’ve using the default format:

WRITE(unit,*) variable

Most likely this is the problem. If you want a specific format, you need to include a format specification. Otherwise the compiler is free to choose the format.

  • Mat