Skip to content
Permalink
Browse files

using Fortran2003 argument counter instead of gfortran builtin

 * from commits 8d435e0 and fea79dd in master
  • Loading branch information...
alexander-buerger-met-no committed Mar 14, 2017
1 parent 2b32c15 commit f41a7043740e218c10eb3df16f171aa6b6dcceb9
Showing with 14 additions and 18 deletions.
  1. +4 −5 modules/F90/fimex2d_example.F90
  2. +8 −9 modules/F90/fortran_test.f90
  3. +1 −2 modules/F90/run.sh
  4. +1 −2 modules/F90/run_example2d.sh
@@ -12,7 +12,6 @@ PROGRAM FIMEX2D_EXAMPLE
CHARACTER(LEN=1024) :: DIMNAME_T
CHARACTER(LEN=10) :: CDTG
INTEGER :: I,T
INTEGER,EXTERNAL :: IARGC
INTEGER(KIND=IKIND) :: NX,NY
LOGICAL :: FOUND12
TYPE(FIMEXIO) :: FIO_IN,FIO_OUT
@@ -23,14 +22,14 @@ PROGRAM FIMEX2D_EXAMPLE
INTEGER :: NTIMES,IERR

! Set arguments
IF ((IARGC() /= 3 ) .AND. (IARGC() /= 4 ) ) THEN
IF ((COMMAND_ARGUMENT_COUNT() /= 3 ) .AND. (COMMAND_ARGUMENT_COUNT() /= 4 ) ) THEN
WRITE(*,*) "Usage: ./fimex2d_example infile outfile infile-fileformat [configfile]"
CALL ABORT
ENDIF

CONFIGFILE=""
DO I = 1, IARGC()
CALL GETARG(I, ARG)
DO I = 1, COMMAND_ARGUMENT_COUNT()
CALL GET_COMMAND_ARGUMENT(I, ARG)
SELECT CASE (I)
CASE(1)
INFILE=ARG
@@ -50,7 +49,7 @@ PROGRAM FIMEX2D_EXAMPLE
CALL ABORT
END SELECT
CASE(4)
IF (IARGC() == 4 ) THEN
IF (COMMAND_ARGUMENT_COUNT() == 4 ) THEN
CONFIGFILE=ARG
ENDIF
END SELECT
@@ -4,7 +4,7 @@ PROGRAM fortran_test
USE Fimex, ONLY : FimexIO, set_filetype, AXIS_GeoX, AXIS_GeoY, AXIS_Lon, AXIS_Lat,INTERPOL_BILINEAR,&
FILETYPE_RW
IMPLICIT NONE
TYPE(FimexIO) :: fio, finter, frw
TYPE(FimexIO) :: fio, finter, finter2, frw
INTEGER :: ierr,i
CHARACTER(LEN=80) :: input_file
CHARACTER(LEN=80) :: config_file
@@ -21,21 +21,20 @@ PROGRAM fortran_test
INTEGER(KIND=8) :: vars
CHARACTER(LEN=10) :: cunit,cfiletype
CHARACTER(LEN=1024) :: dimname
INTEGER,EXTERNAL :: iargc


IF (( iargc() /= 4 ) .AND. ( iargc() /= 5 )) THEN
IF (( COMMAND_ARGUMENT_COUNT() /= 4 ) .AND. ( COMMAND_ARGUMENT_COUNT() /= 5 )) THEN
WRITE(*,*) "Usage: ./fortran_test input-file file-type variable unit [config]"
WRITE(*,*) "Example ./fortran_test /opdata/arome_norway25/AROME_Norway25_00.nc netcdf surface_air_pressure hPa"
WRITE(*,*) " ./fortran_test /opdata/arome_norway25/preprod/AROME_Norway25_00.dat felt surface_air_pressure "//&
"hPa ~/metop/arome_norway25/etc/AromeFeltReaderConfig.xml"
ELSE
CALL getarg(1,input_file)
CALL getarg(2,cfiletype)
CALL getarg(3,varName)
CALL getarg(4,cunit)
IF ( iargc() == 5 ) THEN
CALL getarg(5,config_file)
CALL GET_COMMAND_ARGUMENT(1,input_file)
CALL GET_COMMAND_ARGUMENT(2,cfiletype)
CALL GET_COMMAND_ARGUMENT(3,varName)
CALL GET_COMMAND_ARGUMENT(4,cunit)
IF ( COMMAND_ARGUMENT_COUNT() == 5 ) THEN
CALL GET_COMMAND_ARGUMENT(5,config_file)
ELSE
config_file = ""
ENDIF
@@ -3,6 +3,5 @@ FIMEXDIR=/disk1/fimexTrunk/
set -x
ncgen -b testOut.cdl
gfortran -g -c fimex.f90 && \
gcc -g -c _gfortran_iargc.c && \
gfortran -g -o fortran_test fortran_test.f90 fimex.o _gfortran_iargc.o -L$FIMEXDIR/lib -lfimex -Wl,-rpath,$FIMEXDIR/lib && \
gfortran -g -o fortran_test fortran_test.f90 fimex.o -L$FIMEXDIR/lib -lfimex -Wl,-rpath,$FIMEXDIR/lib && \
./fortran_test /opdata/arome_norway25/AROME_Norway25_00.nc netcdf surface_air_pressure hPa
@@ -6,8 +6,7 @@ fimex=/usr
ncgen -b fimex2d_example.cdl -o fimex2d_example.nc4
fimex --input.file=/opdata/arome2_5_main/AROME_MetCoOp_00_fp.nc --output.file=fimex2d_example_all.nc4 --extract.selectVariables=x --extract.selectVariables=y --extract.selectVariables=longitude --extract.selectVariables=latitude

gcc -c _gfortran_iargc.c || exit 1
gfortran -O3 -Wall -Werror fimex2d_example.F90 -o fimex2d_example -I$fimex/include -I. -L$fimex/lib/ -lfimexf -lfimex _gfortran_iargc.o -Wall -Werror -Wl,-rpath=$fimex/lib/ || exit 1
gfortran -O3 -Wall -Werror fimex2d_example.F90 -o fimex2d_example -I$fimex/include -I. -L$fimex/lib/ -lfimexf -lfimex -Wall -Werror -Wl,-rpath=$fimex/lib/ || exit 1

./fimex2d_example /opdata/arome2_5_main/AROME_MetCoOp_00_fp.nc fimex2d_example.nc4 netcdf || exit 1

0 comments on commit f41a704

Please sign in to comment.
You can’t perform that action at this time.