| 1 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/eeset_parms.F,v 1.16 2004/02/24 16:54:46 cnh Exp $ |
| 2 |
C $Name: $ |
| 3 |
|
| 4 |
#include "CPP_EEOPTIONS.h" |
| 5 |
|
| 6 |
CBOP |
| 7 |
C !ROUTINE: EESET_PARMS |
| 8 |
|
| 9 |
C !INTERFACE: |
| 10 |
SUBROUTINE EESET_PARMS |
| 11 |
IMPLICIT NONE |
| 12 |
|
| 13 |
C !DESCRIPTION: |
| 14 |
C *==========================================================* |
| 15 |
C | SUBROUTINE EESET_PARMS |
| 16 |
C | o Routine to set model "parameters" |
| 17 |
C *==========================================================* |
| 18 |
C | This routine is called from the high-level wrapper |
| 19 |
C | after multi-process paralle processing has started but |
| 20 |
C | before multi-threaded parallelism. THe routine reads an |
| 21 |
C | an "execution environment" input parameter file holding |
| 22 |
C | information about the number of threads at run-time. |
| 23 |
C *==========================================================* |
| 24 |
|
| 25 |
C !USES: |
| 26 |
C == Global variables == |
| 27 |
#include "SIZE.h" |
| 28 |
#include "EEPARAMS.h" |
| 29 |
#include "EESUPPORT.h" |
| 30 |
INTEGER IFNBLNK |
| 31 |
EXTERNAL IFNBLNK |
| 32 |
INTEGER ILNBLNK |
| 33 |
EXTERNAL ILNBLNK |
| 34 |
|
| 35 |
C !LOCAL VARIABLES: |
| 36 |
C == Local variables == |
| 37 |
C iUnit :: Work variable for IO unit number |
| 38 |
C errIO :: IO unit error flag |
| 39 |
C IL :: Temp. for index strings |
| 40 |
C msgBuf :: Temp. for textual I/O |
| 41 |
C record :: Temp. for textual I/O |
| 42 |
INTEGER IL |
| 43 |
INTEGER errIO |
| 44 |
INTEGER iUnit |
| 45 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
| 46 |
CHARACTER*(MAX_LEN_PREC) record |
| 47 |
NAMELIST /EEPARMS/ |
| 48 |
& nTx, nTy, usingMPI, useCoupler, useCubedSphereExchange |
| 49 |
CEOP |
| 50 |
|
| 51 |
|
| 52 |
C-- For now these options are fixed as the code does |
| 53 |
C not fully support features for overlapping communication |
| 54 |
C and computation. |
| 55 |
usingSyncMessages = .TRUE. |
| 56 |
|
| 57 |
C-- Text map plots of fields ignore exact zero values |
| 58 |
printMapIncludesZeros = .FALSE. |
| 59 |
|
| 60 |
C-- The remaining parameters here are set to default values. |
| 61 |
C-- and then any different values are read from an input |
| 62 |
C-- file called "eedata". |
| 63 |
C The defaults set here are for serial execution. |
| 64 |
C |
| 65 |
C nTx and nTy are the number of threads in the X and Y |
| 66 |
C directions. |
| 67 |
C nSx/nTx and nSy/nTy be whole numbers at present. |
| 68 |
C |
| 69 |
C notUsingXPeriodicity and notUsingYPeriodicity affect |
| 70 |
C the identifying of neighbor processes in a multi-process |
| 71 |
C mode. On the whole the numerical model code should not |
| 72 |
C customise itself based on these numbers as they may be |
| 73 |
C removed if they do not prove useful. |
| 74 |
C |
| 75 |
C usingMPI is a flag which controls whether MPI message |
| 76 |
C passing library calls are actually made. Note that under |
| 77 |
C MPI it is necessary to start a program a special way - |
| 78 |
C normally using a command of the form |
| 79 |
C % mpirun program_name |
| 80 |
C If usingMPI is set to TRUE but % mpirun .... was not |
| 81 |
C used to launch the program then an internal MPI error |
| 82 |
C may be generated when the first MPI call ( CALL MPI_Init ) |
| 83 |
C is made. |
| 84 |
C |
| 85 |
C useCoupler is a flag which controls communications with other |
| 86 |
C model components through a coupler interface. |
| 87 |
C |
| 88 |
notUsingXPeriodicity = .FALSE. |
| 89 |
notUsingYPeriodicity = .FALSE. |
| 90 |
useCubedSphereExchange = .FALSE. |
| 91 |
usingMPI = .FALSE. |
| 92 |
useCoupler = .FALSE. |
| 93 |
useCoupler = .TRUE. |
| 94 |
nTx = 1 |
| 95 |
nTy = 1 |
| 96 |
|
| 97 |
C-- Read in data from eedata file |
| 98 |
C We really ought to be using our environment file reading |
| 99 |
C package - but we have not written it yet. |
| 100 |
|
| 101 |
C Make scratch copies of input data file with and without comments |
| 102 |
OPEN(UNIT=scrUnit1,STATUS='SCRATCH') |
| 103 |
OPEN(UNIT=scrUnit2,STATUS='SCRATCH') |
| 104 |
OPEN(UNIT=eeDataUnit,FILE='eedata',STATUS='OLD', |
| 105 |
& err=1,IOSTAT=errIO) |
| 106 |
IF ( errIO .GE. 0 ) GOTO 2 |
| 107 |
1 CONTINUE |
| 108 |
WRITE(msgBuf,'(A)') |
| 109 |
& 'S/R EESET_PARMS' |
| 110 |
CALL PRINT_ERROR( msgBuf , 1) |
| 111 |
WRITE(msgBuf,'(A)') |
| 112 |
& 'Unable to open execution environment' |
| 113 |
CALL PRINT_ERROR( msgBuf , 1) |
| 114 |
WRITE(msgBuf,'(A)') |
| 115 |
& 'parameter file "eedata"' |
| 116 |
CALL PRINT_ERROR( msgBuf , 1) |
| 117 |
CALL EEDATA_EXAMPLE |
| 118 |
STOP 'ABNORMAL END: S/R EESET_PARMS' |
| 119 |
2 CONTINUE |
| 120 |
1000 CONTINUE |
| 121 |
READ(eeDataUnit,FMT='(A)',END=1001) RECORD |
| 122 |
IL = MAX(ILNBLNK(RECORD),1) |
| 123 |
IF ( RECORD(1:1) .NE. commentCharacter ) THEN |
| 124 |
CALL NML_SET_TERMINATOR( RECORD ) |
| 125 |
WRITE(UNIT=scrUnit1,FMT='(A)') RECORD(:IL) |
| 126 |
ENDIF |
| 127 |
WRITE(UNIT=scrUnit2,FMT='(A)') RECORD(:IL) |
| 128 |
GOTO 1000 |
| 129 |
1001 CONTINUE |
| 130 |
CLOSE(eeDataUnit) |
| 131 |
C-- Report contents of parameter file |
| 132 |
WRITE(msgBuf,'(A)') |
| 133 |
& '// =======================================================' |
| 134 |
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
| 135 |
WRITE(msgBuf,'(A)') |
| 136 |
& '// Execution Environment parameter file "eedata"' |
| 137 |
CALL PRINT_MESSAGE(msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
| 138 |
WRITE(msgBuf,'(A)') |
| 139 |
& '// =======================================================' |
| 140 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 141 |
& SQUEEZE_RIGHT , 1) |
| 142 |
|
| 143 |
iUnit = scrUnit2 |
| 144 |
REWIND(iUnit) |
| 145 |
2000 CONTINUE |
| 146 |
READ(UNIT=iUnit,FMT='(A)',END=2001) RECORD |
| 147 |
IL = MAX(ILNBLNK(RECORD),1) |
| 148 |
WRITE(msgBuf,'(A,A)') '>',RECORD(:IL) |
| 149 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit, SQUEEZE_RIGHT , 1) |
| 150 |
GOTO 2000 |
| 151 |
2001 CONTINUE |
| 152 |
CLOSE(iUnit) |
| 153 |
|
| 154 |
WRITE(msgBuf,'(A)') ' ' |
| 155 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
| 156 |
& SQUEEZE_RIGHT , 1) |
| 157 |
|
| 158 |
iUnit = scrUnit1 |
| 159 |
REWIND(iUnit) |
| 160 |
READ(UNIT=iUnit,NML=EEPARMS,IOSTAT=errIO,err=3) |
| 161 |
IF ( errIO .GE. 0 ) GOTO 4 |
| 162 |
3 CONTINUE |
| 163 |
#ifndef TARGET_PWR3 |
| 164 |
WRITE(msgBuf,'(A)') |
| 165 |
& 'S/R EESET_PARMS' |
| 166 |
CALL PRINT_ERROR( msgBuf , 1) |
| 167 |
WRITE(msgBuf,'(A)') |
| 168 |
& 'Error reading execution environment ' |
| 169 |
CALL PRINT_ERROR( msgBuf , 1) |
| 170 |
WRITE(msgBuf,'(A)') |
| 171 |
& 'parameter file "eedata"' |
| 172 |
CALL PRINT_ERROR( msgBuf , 1) |
| 173 |
CALL EEDATA_EXAMPLE |
| 174 |
STOP 'ABNORMAL END: S/R EESET_PARMS' |
| 175 |
#endif |
| 176 |
4 CONTINUE |
| 177 |
|
| 178 |
C-- Execution Environment parameter file read |
| 179 |
CLOSE(iUnit) |
| 180 |
|
| 181 |
Cdbg eeDataUnit = 42 |
| 182 |
Cdbg OPEN(UNIT=eeDataUnit,FILE='eedata',STATUS='OLD',IOSTAT=errIO) |
| 183 |
Cdbg IF ( errIO .LT. 0 ) GOTO 11 |
| 184 |
Cdbg DO K=1, 10 |
| 185 |
Cdbg READ(eedataUnit,IOSTAT=errIO) |
| 186 |
Cdbg IF ( errIO .LT. 0 ) GOTO 11 |
| 187 |
Cdbg ENDDO |
| 188 |
Cdbg READ(eedataUnit,FMT='(30X,1X,L23)',IOSTAT=errIO) notUsingXPeriodicity |
| 189 |
Cdbg IF ( errIO .LT. 0 ) GOTO 11 |
| 190 |
Cdbg READ(eedataUnit,FMT='(30X,1X,L23)',IOSTAT=errIO) notUsingYPeriodicity |
| 191 |
Cdbg IF ( errIO .LT. 0 ) GOTO 11 |
| 192 |
Cdbg READ(eedataUnit,FMT='(30X,1X,L23)',IOSTAT=errIO) usingMPI |
| 193 |
Cdbg IF ( errIO .LT. 0 ) GOTO 11 |
| 194 |
Cdbg READ(eedataUnit,FMT='(30X,1X,I3)',IOSTAT=errIO) nTx |
| 195 |
Cdbg IF ( errIO .LT. 0 ) GOTO 11 |
| 196 |
Cdbg READ(eedataUnit,FMT='(30X,1X,I3)',IOSTAT=errIO) nTy |
| 197 |
|
| 198 |
|
| 199 |
Cdbg IF (errIO .LT. 0 ) eeBootError = .TRUE. |
| 200 |
Cdbg CLOSE(eeDataUnit,IOSTAT=errIO) |
| 201 |
Cdbg IF ( eeBootError .OR. errIO .LT. 0 ) THEN |
| 202 |
C-- Report that an error occured |
| 203 |
Cdbg eeBootError = .TRUE. |
| 204 |
Cdbg WRITE(msgBuf,'(A)' ) |
| 205 |
Cdbg & 'S/R EESET_PARMS: Error reading "eedata" execution environment file' |
| 206 |
Cdbg CALL PRINT_ERROR( msgBuf , 1) |
| 207 |
Cdbg ELSE |
| 208 |
C-- Write summary of settings that were selected |
| 209 |
Cdbg ENDIF |
| 210 |
C |
| 211 |
C |
| 212 |
RETURN |
| 213 |
END |