Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:37:51 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
97d49af5d4 Jean*0001 #include "AUTODIFF_OPTIONS.h"
                0002 
                0003 C     ==================================================================
                0004 C     active_file_gen.F: Routines to handle the I/O of the active file
                0005 C                        for the adjoint calculations.
                0006 C     Routines
                0007 C    o  ACTIVE_READ_GEN_RL     - Read  an active RL variable from file.
                0008 C    o  ACTIVE_READ_GEN_RS     - Read  an active RS variable from file.
                0009 C
                0010 C    o  ACTIVE_WRITE_GEN_RL    - Write an active RL variable to a file.
                0011 C    o  ACTIVE_WRITE_GEN_RS    - Write an active RS variable to a file.
                0012 C
                0013 C     Generic version for each array type (_RL or _RS).
                0014 C     Note: the _RL version can replace the 4 x 2 shape-specific
db46a9c7cf Jean*0015 C           (_xy,_xyz,_xz,_yz) and standard or "_loc" routines.
97d49af5d4 Jean*0016 C     ==================================================================
                0017 
                0018 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0019 CBOP
                0020 C     !ROUTINE: ACTIVE_READ_GEN_RL
                0021 C     !INTERFACE:
                0022       SUBROUTINE ACTIVE_READ_GEN_RL(
                0023      I                               activeVar_file,
                0024      O                               active_var,
                0025      I                               arrShape, myNr,
                0026      I                               iRec,
                0027      I                               globalFile,
                0028      I                               useCurrentDir,
                0029      I                               lAdInit,
                0030      I                               myOptimIter,
                0031      I                               myThid,
                0032      I                               dummy )
                0033 
                0034 C     !DESCRIPTION: \bv
                0035 C     ==================================================================
                0036 C     SUBROUTINE ACTIVE_READ_GEN_RL
                0037 C     ==================================================================
                0038 C     o Read an active (_RL) variable from file (generic version).
                0039 C     Accept active variable of various (XY,XZ,YZ) shape and level
                0040 C     number, according to arguments arrShape and myNr.
                0041 C     ==================================================================
                0042 C     \ev
                0043 
                0044 C     !USES:
                0045       IMPLICIT NONE
                0046 
                0047 C     == global variables ==
                0048 #include "EEPARAMS.h"
                0049 
                0050 C     !INPUT/OUTPUT PARAMETERS:
                0051 C     activeVar_file :: filename
                0052 C     active_var     :: active variable array
                0053 C     arrShape       :: shape of active-var array ('XY','XZ' or 'YZ')
                0054 C     myNr           :: number of vertical-levels in active-var array
                0055 C     iRec           :: record number in file
                0056 C     globalFile     :: used for writing global (if =T) or tiled files
                0057 C     useCurrentDir  :: always read from the current directory
                0058 C                        (even if "mdsioLocalDir" is set)
                0059 C     lAdInit        :: initialisation of corresponding adjoint variable
                0060 C                        and write to active file
                0061 C     myOptimIter    :: number of optimization iteration (default: 0)
                0062 C     myThid         :: my Thread Id number
                0063 C     dummy          :: (needed for 2nd derivative code)
                0064       CHARACTER*(*) activeVar_file
                0065       _RL     active_var(*)
                0066       CHARACTER*(2) arrShape
                0067       INTEGER myNr
                0068       INTEGER iRec
                0069       LOGICAL globalFile
                0070       LOGICAL useCurrentDir
                0071       LOGICAL lAdInit
                0072       INTEGER myOptimIter
                0073       INTEGER myThid
                0074       _RL     dummy
                0075 
                0076 C     !LOCAL VARIABLES:
                0077 CEOP
                0078 
                0079       IF ( arrShape.EQ.'XY' ) THEN
                0080 
                0081         CALL ACTIVE_READ_3D_RL(
                0082      &                 activeVar_file, active_var, globalFile,
                0083      &                 useCurrentDir, lAdInit, iRec, myNr,
                0084      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0085 
                0086       ELSEIF ( arrShape.EQ.'XZ' ) THEN
                0087 
                0088         CALL ACTIVE_READ_XZ_RL(
                0089      &                 activeVar_file, active_var, globalFile,
                0090      &                 useCurrentDir, lAdInit, iRec, myNr,
                0091      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0092 
                0093       ELSEIF ( arrShape.EQ.'YZ' ) THEN
                0094 
                0095         CALL ACTIVE_READ_YZ_RL(
                0096      &                 activeVar_file, active_var, globalFile,
                0097      &                 useCurrentDir, lAdInit, iRec, myNr,
                0098      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0099 
                0100       ELSE
                0101         STOP
                0102      &   'ABNORMAL END: S/R ACTIVE_READ_GEN_RL: invalid arrShape'
                0103       ENDIF
                0104 
                0105       RETURN
                0106       END
                0107 
                0108 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0109 CBOP
                0110 C     !ROUTINE: ACTIVE_READ_GEN_RS
                0111 C     !INTERFACE:
                0112       SUBROUTINE ACTIVE_READ_GEN_RS(
                0113      I                               activeVar_file,
                0114      O                               active_var,
                0115      I                               arrShape, myNr,
                0116      I                               iRec,
                0117      I                               globalFile,
                0118      I                               useCurrentDir,
                0119      I                               lAdInit,
                0120      I                               myOptimIter,
                0121      I                               myThid,
                0122      I                               dummy )
                0123 
                0124 C     !DESCRIPTION: \bv
                0125 C     ==================================================================
                0126 C     SUBROUTINE ACTIVE_READ_GEN_RS
                0127 C     ==================================================================
                0128 C     o Read an active (_RS) variable from file (generic version).
                0129 C     Accept active variable of various (XY,XZ,YZ) shape and level
                0130 C     number, according to arguments arrShape and myNr.
                0131 C     ==================================================================
                0132 C     \ev
                0133 
                0134 C     !USES:
                0135       IMPLICIT NONE
                0136 
                0137 C     == global variables ==
                0138 #include "EEPARAMS.h"
                0139 
                0140 C     !INPUT/OUTPUT PARAMETERS:
                0141 C     activeVar_file :: filename
                0142 C     active_var     :: active variable array
                0143 C     arrShape       :: shape of active-var array ('XY','XZ' or 'YZ')
                0144 C     myNr           :: number of vertical-levels in active-var array
                0145 C     iRec           :: record number in file
                0146 C     globalFile     :: used for writing global (if =T) or tiled files
                0147 C     useCurrentDir  :: always read from the current directory
                0148 C                        (even if "mdsioLocalDir" is set)
                0149 C     lAdInit        :: initialisation of corresponding adjoint variable
                0150 C                        and write to active file
                0151 C     myOptimIter    :: number of optimization iteration (default: 0)
                0152 C     myThid         :: my Thread Id number
                0153 C     dummy          :: (needed for 2nd derivative code)
                0154       CHARACTER*(*) activeVar_file
                0155       _RS     active_var(*)
                0156       CHARACTER*(2) arrShape
                0157       INTEGER myNr
                0158       INTEGER iRec
                0159       LOGICAL globalFile
                0160       LOGICAL useCurrentDir
                0161       LOGICAL lAdInit
                0162       INTEGER myOptimIter
                0163       INTEGER myThid
                0164       _RS     dummy
                0165 
                0166 C     !LOCAL VARIABLES:
                0167 CEOP
                0168 
                0169       IF ( arrShape.EQ.'XY' ) THEN
                0170 
                0171         CALL ACTIVE_READ_3D_RS(
                0172      &                 activeVar_file, active_var, globalFile,
                0173      &                 useCurrentDir, lAdInit, iRec, myNr,
                0174      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0175 
                0176       ELSEIF ( arrShape.EQ.'XZ' ) THEN
                0177 
                0178         CALL ACTIVE_READ_XZ_RS(
                0179      &                 activeVar_file, active_var, globalFile,
                0180      &                 useCurrentDir, lAdInit, iRec, myNr,
                0181      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0182 
                0183       ELSEIF ( arrShape.EQ.'YZ' ) THEN
                0184 
                0185         CALL ACTIVE_READ_YZ_RS(
                0186      &                 activeVar_file, active_var, globalFile,
                0187      &                 useCurrentDir, lAdInit, iRec, myNr,
                0188      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0189 
                0190       ELSE
                0191         STOP
                0192      &   'ABNORMAL END: S/R ACTIVE_READ_GEN_RS: invalid arrShape'
                0193       ENDIF
                0194 
                0195       RETURN
                0196       END
                0197 
                0198 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0199 CBOP
                0200 C     !ROUTINE: ACTIVE_WRITE_GEN_RL
                0201 C     !INTERFACE:
                0202       SUBROUTINE ACTIVE_WRITE_GEN_RL(
                0203      I                               activeVar_file,
                0204      I                               active_var,
                0205      I                               arrShape, myNr,
                0206      I                               iRec,
                0207      I                               useCurrentDir,
                0208      I                               myOptimIter,
                0209      I                               myThid,
                0210      I                               dummy )
                0211 
                0212 C     !DESCRIPTION: \bv
                0213 C     ==================================================================
                0214 C     SUBROUTINE ACTIVE_WRITE_GEN_RL
                0215 C     ==================================================================
                0216 C     o Write an active (_RL) variable from file (generic version).
                0217 C     Accept active variable of various (XY,XZ,YZ) shape and level
                0218 C     number, according to arguments arrShape and myNr.
                0219 C     ==================================================================
                0220 C     \ev
                0221 
                0222 C     !USES:
                0223       IMPLICIT NONE
                0224 
                0225 C     == global variables ==
                0226 #include "EEPARAMS.h"
                0227 
                0228 C     !INPUT/OUTPUT PARAMETERS:
                0229 C     activeVar_file :: filename
                0230 C     active_var     :: active variable array
                0231 C     arrShape       :: shape of active-var array ('XY','XZ' or 'YZ')
                0232 C     myNr           :: number of vertical-levels in active-var array
                0233 C     iRec           :: record number in file
                0234 C     useCurrentDir  :: always write to the current directory
                0235 C                        (even if "mdsioLocalDir" is set)
                0236 C     myOptimIter    :: number of optimization iteration (default: 0)
                0237 C     myThid         :: my Thread Id number
                0238 C     dummy          :: (needed for 2nd derivative code)
                0239       CHARACTER*(*) activeVar_file
                0240       _RL     active_var(*)
                0241       CHARACTER*(2) arrShape
                0242       INTEGER myNr
                0243       INTEGER iRec
                0244       LOGICAL useCurrentDir
                0245       INTEGER myOptimIter
                0246       INTEGER myThid
                0247       _RL     dummy
                0248 
                0249 C     !LOCAL VARIABLES:
                0250 C     globalFile     :: used for writing global (if =T) or tiled files
                0251       LOGICAL globalFile
                0252 CEOP
                0253 
                0254       globalFile = .FALSE.
                0255       IF ( arrShape.EQ.'XY' ) THEN
                0256 
                0257         CALL ACTIVE_WRITE_3D_RL(
                0258      &                 activeVar_file, active_var, globalFile,
                0259      &                 useCurrentDir, iRec, myNr,
                0260      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0261 
                0262       ELSEIF ( arrShape.EQ.'XZ' ) THEN
                0263 
                0264         CALL ACTIVE_WRITE_XZ_RL(
                0265      &                 activeVar_file, active_var, globalFile,
                0266      &                 useCurrentDir, iRec, myNr,
                0267      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0268 
                0269       ELSEIF ( arrShape.EQ.'YZ' ) THEN
                0270 
                0271         CALL ACTIVE_WRITE_YZ_RL(
                0272      &                 activeVar_file, active_var, globalFile,
                0273      &                 useCurrentDir, iRec, myNr,
                0274      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0275 
                0276       ELSE
                0277         STOP
                0278      &   'ABNORMAL END: S/R ACTIVE_WRITE_GEN_RL: invalid arrShape'
                0279       ENDIF
                0280 
                0281       RETURN
                0282       END
                0283 
                0284 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0285 CBOP
                0286 C     !ROUTINE: ACTIVE_WRITE_GEN_RS
                0287 C     !INTERFACE:
                0288       SUBROUTINE ACTIVE_WRITE_GEN_RS(
                0289      I                               activeVar_file,
                0290      I                               active_var,
                0291      I                               arrShape, myNr,
                0292      I                               iRec,
                0293      I                               useCurrentDir,
                0294      I                               myOptimIter,
                0295      I                               myThid,
                0296      I                               dummy )
                0297 
                0298 C     !DESCRIPTION: \bv
                0299 C     ==================================================================
                0300 C     SUBROUTINE ACTIVE_WRITE_GEN_RS
                0301 C     ==================================================================
                0302 C     o Write an active (_RS) variable from file (generic version).
                0303 C     Accept active variable of various (XY,XZ,YZ) shape and level
                0304 C     number, according to arguments arrShape and myNr.
                0305 C     ==================================================================
                0306 C     \ev
                0307 
                0308 C     !USES:
                0309       IMPLICIT NONE
                0310 
                0311 C     == global variables ==
                0312 #include "EEPARAMS.h"
                0313 
                0314 C     !INPUT/OUTPUT PARAMETERS:
                0315 C     activeVar_file :: filename
                0316 C     active_var     :: active variable array
                0317 C     arrShape       :: shape of active-var array ('XY','XZ' or 'YZ')
                0318 C     myNr           :: number of vertical-levels in active-var array
                0319 C     iRec           :: record number in file
                0320 C     useCurrentDir  :: always write to the current directory
                0321 C                        (even if "mdsioLocalDir" is set)
                0322 C     myOptimIter    :: number of optimization iteration (default: 0)
                0323 C     myThid         :: my Thread Id number
                0324 C     dummy          :: (needed for 2nd derivative code)
                0325       CHARACTER*(*) activeVar_file
                0326       _RS     active_var(*)
                0327       CHARACTER*(2) arrShape
                0328       INTEGER myNr
                0329       INTEGER iRec
                0330       LOGICAL useCurrentDir
                0331       INTEGER myOptimIter
                0332       INTEGER myThid
                0333       _RS     dummy
                0334 
                0335 C     !LOCAL VARIABLES:
                0336 C     globalFile     :: used for writing global (if =T) or tiled files
                0337       LOGICAL globalFile
                0338 CEOP
                0339 
                0340       globalFile = .FALSE.
                0341       IF ( arrShape.EQ.'XY' ) THEN
                0342 
                0343         CALL ACTIVE_WRITE_3D_RS(
                0344      &                 activeVar_file, active_var, globalFile,
                0345      &                 useCurrentDir, iRec, myNr,
                0346      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0347 
                0348       ELSEIF ( arrShape.EQ.'XZ' ) THEN
                0349 
                0350         CALL ACTIVE_WRITE_XZ_RS(
                0351      &                 activeVar_file, active_var, globalFile,
                0352      &                 useCurrentDir, iRec, myNr,
                0353      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0354 
                0355       ELSEIF ( arrShape.EQ.'YZ' ) THEN
                0356 
                0357         CALL ACTIVE_WRITE_YZ_RS(
                0358      &                 activeVar_file, active_var, globalFile,
                0359      &                 useCurrentDir, iRec, myNr,
                0360      &                 FORWARD_SIMULATION, myOptimIter, myThid )
                0361 
                0362       ELSE
                0363         STOP
                0364      &   'ABNORMAL END: S/R ACTIVE_WRITE_GEN_RS: invalid arrShape'
                0365       ENDIF
                0366 
                0367       RETURN
                0368       END