intel-fortran

Reading writing fortran direct access unformatted files with different compilers

你。 提交于 2019-11-27 14:31:32
I have a section in a program that writes a direct-access binary file as follows: open (53, file=filename, form='unformatted', status='unknown', & access='direct',action='write',recl=320*385*8) write (53,rec=1) ulat write (53,rec=2) ulng close(53) This program is compiled with ifort. However, I cannot reconstruct the data correctly if I read the data file from a different program compiled with gfortran. If the program reading the data is also compiled in ifort, then I can correctly reconstruct the data. Here's the code reading the data file: OPEN(53, FILE=fname, form="unformatted", status=

Concatenating an expanded macro and a word using the Fortran preprocessor

别等时光非礼了梦想. 提交于 2019-11-27 08:17:45
问题 I'm trying to concatenate a word in the source code with the expansion of a preprocessor macro. Basically I have foo somewhere in the code, and with a #define EXPANSION bar I want to obtain foobar . However, I'm struggling to find a way to do this, which works with all compilers. For the moment I would be happy if it works with gfortran and ifort. According to its documentation, the gfortran preprocessor is a C preprocessor running in "traditional mode", which does not have the ## token paste

Why direct access I/O works incorrectly with Intel Visual Fortran

南笙酒味 提交于 2019-11-26 23:39:38
问题 This program program test real a(10) open(1, file='f1',access='direct', recl=20) do i=1, 10 a(i) = i-1 end do write(1, rec=1)(a(i),i=1,5) write(1, rec=2)(a(i),i=6,10) close(1) open(1, file='f1',access='direct',recl=8) read(1, rec=4)(a(i),i =5,9,4) print*,a end works incorrect in visual Fortran (incorrect): 0.0000000E+00 1.000000 2.000000 3.000000 9.000000 5.000000 6.000000 7.000000 0.0000000E+00 9.000000 Result in WATCOM (correct): 0.0000000 1.0000000 2.0000000 3.0000000 6.0000000 5.0000000 6

Reading writing fortran direct access unformatted files with different compilers

穿精又带淫゛_ 提交于 2019-11-26 16:47:35
问题 I have a section in a program that writes a direct-access binary file as follows: open (53, file=filename, form='unformatted', status='unknown', & access='direct',action='write',recl=320*385*8) write (53,rec=1) ulat write (53,rec=2) ulng close(53) This program is compiled with ifort. However, I cannot reconstruct the data correctly if I read the data file from a different program compiled with gfortran. If the program reading the data is also compiled in ifort, then I can correctly

Correct suffix for Fortran 2003 source file - Intel Fortran compiler

眉间皱痕 提交于 2019-11-26 09:13:16
问题 I\'ve written a small snippet of code, trying to adhere to the Fortran 2003 standard. The code is available on github. This is my makefile: FC = gfortran FLGS = -g -pg -std=f2003 -I. -fbounds-check DEPS = camx.prm OBJ = unit-test-hadvppm.o hadvppm.o #linker macro %.o: %.f03 $(DEPS) $(FC) -c -o $@ $< $(FLGS) #build targets gnu-amd64-linux: $(OBJ) $(FC) -o $@ $^ $(FLGS) clean: gnu-amd64-linux rm *.o The code compiles without a problem using the above makefile and gfortran . However, if I try to

Format string for output dependent on a variable

浪子不回头ぞ 提交于 2019-11-26 07:39:35
问题 I would like to have a Fortran write statement formatted to depend on some variable. For example, I could write: write(*,\'(3f15.3,3f9.2)\') x,y,z,(var(i),i=1,nvari) where nvari = 3 . But, what if, in some cases, I actually have 4 variables (i.e. nvari = 4 ). I would like to write something like this: write(*,\'(3f15.3,nvari(f9.2))\') x,y,z,(var(i),i=1,nvari) Now, nvari can be anything and the output will work as I like. How can I make something like this work? 回答1: If you are using Intel