program test IMPLICIT NONE integer a,andrew,x,ifetch,dfetch,ffetch doubleprecision gp_dfetch integer gp_ifetch C real gp_ffetch real b,david integer debug,y,z doubleprecision c,john,MINFLT,themin INTEGER t, t0, tswap, tdump, tmax, INDI01 INTEGER IERR00,NPROCS,DIMPGR(1),PARINT(100),COMM2D,PPRANK DOUBLE PRECISION PARDPR(100) LOGICAL PERIOD(1),RORDER PARAMETER (RORDER = .FALSE.) C integer count CHARACTER(len=132) arg C.... Fortran/C interface interface subroutine gp_parfile(string) bind(C, name="GP_parfile") use iso_c_binding, only: c_char character(kind=c_char) :: string(*) end subroutine gp_parfile end interface C.... assign parameter values from file include 'parinclude.f' C count = command_argument_count() if (count.lt.1) then CALL get_command_argument(0, arg) print *,'Warning: ',TRIM(arg),' called with no arguments' print *,'will use standard input as parameter file.' else CALL get_command_argument(1, arg) c print *,'Debugging: parfile name is ',TRIM(arg) call gp_parfile(TRIM(arg)) endif include 'parinclude.f' themin = minflt() debug=1 WRITE(6,*) "_____________________________________________________" WRITE(6,*) " Testing Fortran functions " WRITE(6,*) " minflt() =",the min WRITE(6,*) "_____________________________________________________" x = ifetch("andrew",a) y = ffetch("david",b) z = dfetch("john",c) if(x*y*z == 0) then stop 'fetch failed' endif if(andrew.ne.a.or. $ (abs(david-b)).gt.themin.or. $ (abs(john-c)).gt.themin) $ then write(6,*) "abs(david-b) = ",abs(david-b) write(6,*) "abs(john-c) = " ,abs(john-c) stop 'fgp simple test failed' endif if(debug.eq.1) THEN write (6,*) "int andrew=",andrew, " read=",a, "PASS" write (6,*) "float david=",david, " read=",b, "PASS" write (6,*) "double john=",john, " read=",c, "PASS" ENDIF WRITE(6,*) "-----------------------------------------------------" WRITE(6,*) " Testing Fortran GP_xxxx functions " WRITE(6,*) "_____________________________________________________" debug = GP_ifetch("debug",0,"SEVERE") a = GP_ifetch("andrew",0,"DEFAULT") C b = GP_ffetch("david",345.,"DEFAULT") c = GP_dfetch("john",0.D0,"DEFAULT") if(debug.eq.2) then a = GP_ifetch("andrew",0,"WARNING") C b = GP_ffetch("david",0.,"WARNING") c = GP_dfetch("john",0.D0,"WARNING") a = GP_ifetch("noandrew",0,"WARNING") C b = GP_ffetch("nodavid",345.,"WARNING") c = GP_dfetch("nojohn",0.D0,"WARNING") a = GP_ifetch("andrew",0,"SEVERE") C b = GP_ffetch("david",0.,"SEVERE") c = GP_dfetch("john",0.D0,"SEVERE") a = GP_ifetch("noandrew",0,"SEVERE") C b = GP_ffetch("nodavid",0.,"SEVERE") c = GP_dfetch("nojohn",0.D0,"SEVERE") endif if(andrew.ne.a.or. $ (abs(david-b)).gt.themin.or. $ (abs(john-c)).gt.themin) $ stop 'fgp simple test failed' if(debug.eq.1) THEN write (6,*) "int andrew=",andrew, " read=",a, "PASS" write (6,*) "float david=",david, " read=",b, "PASS" write (6,*) "double john=",john, " read=",c, "PASS" ENDIF STOP END