I am trying to do something with some files of same filename pattern, e.g:
data1.dat
data2.dat
data3.dat
...
datan.dat
with
program readoneline
character(1024) :: line, filename
integer :: i, nfile, ifile
nfile = command_argument_count()
do i = 1, nfile
call get_command_argument(i, filename)
open(newunit=ifile, file=trim(filename)
read(ifile, '(A)') line
print*, 'Fist line of'//trim(filename)//' is 'trim(line)
end do
In Windows, if I compile it with Gfortran 8 (comes with rtools), it will expand asterisk (“*”) below to all files:
gfortran -cpp -fbacktrace -ffree-line-length-none -O2 -static -s readoneline.f90 -o readoneline
readoneline.exe data*.dat
However, if I compile it with ifort (Intel(R) 64, Version 2021.5.0 Build 20211109_000000),
ifort -traceback -heap-arrays -O2 -fpe:0 -fpp -nowarn -nologo -static readoneline.f90 -o readoneline
readoneline.exe data*.dat
it will read command line argument verbosely as "data*.dat".
How can I make ifort behave like gfortran? I want to use ifort because it's faster than gfortran.
worked
gfortran -cpp -fbacktrace -ffree-line-length-none -O2 -static -s readoneline.f90 -o readoneline
readoneline.exe data*.dat
not worked
ifort -traceback -heap-arrays -O2 -fpe:0 -fpp -nowarn -nologo -static readoneline.f90 -o readoneline
readoneline.exe data*.dat
Related
As suggested in the answer from the following post, I am trying to build my Fortran program using mpif90 with -acc=gpu flag.
Getting started with OpenACC + MPI Fortran program
I was shown the following error:
gfortran: error: unrecognized command line option ‘-acc=gpu’
I don't understand how I can use mpif90 to compile OpenACC parts of the code. Don't I need a compiler like nvfortran to tell the computer about my OpenACC directives in the code? It's so confusing for me to know how I can tell to the computer about both of my mpi and OpenACC parts of the code simultaneously.
I am posting my make file here for reference:
OBJECTS = Main.o Module.o Pre_processing.o boundary_conditions.o \
interpolation.o viscous_fluxes.o
MODULES = Module.mod
CASE = Riemann.f90
# FC= pgfortran
# FFLAG = -acc -fast -mcmodel=medium -ta=tesla:managed -Minfo=accel
# FFLAG = -fast -mcmodel=medium
FC= mpif90
FFLAG = -acc=gpu
output: a.out
a.out: $(MODULES) $(OBJECTS) cases/$(CASE)
$(FC) $(FFLAG) $(OBJECTS) cases/$(CASE) -o a.out
%.o: %.f90
$(FC) $(FFLAG) -c $<
%.mod: %.f90
$(FC) $(FFLAG) -c $<
.PHONY: clean
clean :
rm -f *.o *.mod *.out *.qdrep
I have following compilers installed on my PC which has two Nvidia A6000 GPU cards:
GNU Fortran (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 & nvfortran 21.9-0 64-bit target on x86-64 Linux -tp zen
Trying to compile C++ program using developerstudio12.6 CC on Solaris intel i386.
compiler do not show errors or warnings but fails.
Possible to figure why CC do not show any warnings or errors - what is possibly going wrong?
developerstudio12.6/bin/CC -mt -xtarget=native -m32 -g -errwarn=%all -O -DNDEBUG -c xml_test.cc -I<some include> -I<some other include> -o xml_test.o
echo $?
2
Using -verbose=template => similar output, no debug lines
Using -# or verbose=diags=> Huge amount of output but no error lines
### CC: Note: NLSPATH = `/opt/developerstudio12.6/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/developerstudio12.6/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat`
### command line files and options (expanded):
### -mt=yes -xtarget=native -xchip=broadwell -xcache=32/64/8/2:256/64/8/2:30720/64/20/24 -xarch=avx2_i -m32 -xdebuginfo=line,param,variable,tagtype,codetag,decl -xglobalize=yes -xpatchpadding=fix -Qoption driver -dconditional=yes -xkeep_unref=funcs,vars -verbose=diags -O3 -DNDEBUG -c xml_test.cc -I<some include> -I<some include> -oxml_test.o
/opt/developerstudio12.6/lib/compilers/bin/ccfe -D__SunOS_5_11 -D__SunOS_RELEASE=0x051100 -D__SUNPRO_CC=0x5150 -D__unix -D__SVR4__ -D__svr4__ -D__SVR4 -D__sun -D__sun__ -D__SunOS -D__i386 -D__i386__ -D__ORDER_LITTLE_ENDIAN__=1234 -D__ORDER_BIG_ENDIAN__=4321 -D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__ -D__BUILTIN_VA_ARG_INCR -Dunix -Dsun -Di386 -D__FP_FAST_FMA__ -D__FP_FAST_FMAF__ -D_REENTRANT -D__SUN_PREFETCH -D__SUNPRO_CC_COMPAT=5 -I<some include> -I<some include> -I-xbuiltin -I/opt/developerstudio12.6/lib/compilers/include/CC/Cstd -I/opt/developerstudio12.6/lib/compilers/include/CC -I/opt/developerstudio12.6/lib/compilers/include/cc -DNDEBUG -ptf /tmp/ccfe.1620226479.15666.03.%1.%2 -ptx /opt/developerstudio12.6/bin/CC -ptk "-mt=yes -xtarget=native -m32 -xdebuginfo=line,param,decl,variable,tagtype,codetag -xglobalize=yes -xpatchpadding=fix -xkeep_unref=funcs,vars -verbose=diags -O3 -DNDEBUG -c -I<some include> -I<some include> " -compat=5 -xglobalize=yes -xdebuginfo=line,param,variable,tagtype,codetag,decl -instlib=/opt/developerstudio12.6/lib/compilers/libCstd.a -xdbggen=dwarf+usedonly+incl+line+param+variable+tagtype+codetag+decl -xF=%none -xbuiltin=%default -xldscope=global -xivdep=loop -xdepend -O3 -xarrayloc xml_test.cc -ptb xml_test.o -o /tmp/ccfe.1620226479.15666.01.ir 2> /tmp/ccfe.1620226479.15666.02.err
/opt/developerstudio12.6/lib/compilers/stdlibfilt -stderr < /tmp/ccfe.1620226479.15666.02.err
Your NLSPATH environment variable is incorrect.
/opt/developerstudio12.6/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat refers to /opt/lib/locale/%L/LC_MESSAGES/%N.cat instead of /opt/developerstudio12.6/lib/locale/%L/LC_MESSAGES/%N.cat because you have an extra .. element in it.
I fixed the issue just a while back by adding -filt=%none to the compiler options:
-mt -xtarget=native -m32 -filt=%none -g2 -verbose=template -errtags -library=iostream
I'm trying to use NetCDF in a Fortran executable that then gets sent out to a lot of machines for parallel computation, so I need it to be statically linked. I'm doing the compiling on my own machine with mpif90, but I've also tried gfortran (Linux, though could also use Windows).
I'd love to build something entirely static, but packaging mpiexec in a static library seems difficult.
Here's a sketch of what I'm doing:
mpif90 -c -o somestuff.o somestuff.f90
mpif90 -c -o thing_that_uses_netCDF.o thing_that_uses_netCDF.f90 \
-I/usr/include -L/usr/lib/x86_64-linux-gnu -lnetcdff
ar cr libintermediate.a thing_that_uses_netCDF.o somestuff.o
mpif90 -c -o downstreamstuff.o downstreamstuff.f90 \
-I./path/to/intermediatelib -L./path/to/intermediatelib -lintermediate \
-I/usr/include -L/usr/lib/x86_64-linux-gnu -lnetcdff
mpif90 -o finalexecutable downstreamstuff.o \
-I./path/to/intermediatelib -L./path/to/intermediatelib -lintermediate \
-I/usr/include -L/usr/lib/x86_64-linux-gnu -lnetcdff
Could someone walk me through linking the netcdff library? When I try it with gfortran if I use the -static flag I get "undefined reference to `__netcdf_MOD..." errors, though it compiles fine without the -static flag.
Thanks.
I have a Fortran 90 code, with OpenMP implemented for some parts. Now to compile the Fortran code using f2py with OpenMP support I have to pass the f90 compiler flags. Now the code should compile with OpenMP support only if I provide the OpenMP relevant flag, unless it must be compiled as a normal serial code. This works as expected for gfortran but for ifort it doesn't. Lets explain this,
if I run,
(gfortran serial mode)
f2py -c adt.f90 -m adt_module
*Gives output (last few lines)*
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
(gfortran parallel mode)
f2py -c adt.f90 -m adt_module --f90flags='-fopenmp' -lgomp
*output*
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -fopenmp -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fopenmp -fPIC -O3 -funroll-loops
As you can clearly see there is no -fopenmp flag during the compilation in serial mode, as expected as I haven't pass the required flag
Now for ifort
(ifort parallel mode)
f2py -c adt.f90 -m adt_module --fcompiler=intelem --f90flags='-qopenmp' -liomp5
*Output*
Fortran f77 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp
Fortran f90 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FR -qopenmp -fPIC -fp-model strict -O1 -qopenmp
Fortran fix compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -qopenmp -fPIC -fp-model strict -O1 -qopenmp
(ifort serial mode)
f2py -c adt.f90 -m adt_module --fcompiler=intelem
*Output*
Fortran f77 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp
Fortran f90 compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FR -fPIC -fp-model strict -O1 -qopenmp
Fortran fix compiler: /opt/intel/compilers_and_libraries_2017.4.196/linux/bin/intel64/ifort -FI -fPIC -fp-model strict -O1 -qopenmp
Now, here's the problem, see here compiling is done with -qopenmp flag for serial mode but I haven't passed it in command line. Why is it happening when compiling with ifort but not with gfortran? And how to resolve this?
I want to use the gfortran diagnostics-color however I cannot see any colors.
I used this command
/home/cdim/Local/gcc-4.9.2/bin/gfortran -ffree-form -J./build/lib- -g -fdiagnostics-color=always -Wall -o ./bin/test_larsa.x ./utests/test_larsa.f ./lib/larsa.f