Skip to content

Commit

Permalink
Update mdsio slice I/O routines (MITgcm#747)
Browse files Browse the repository at this point in the history
* Add 2 new arguments to S/R MDS_READ/WRITE_SEC_X/YZ

New arguments kLo & kHi allow to select which levels in Slice array to fill-in (read)
or to write out to file.
This is (very) similar to 3-D counterpart routines in mdsio_read_field.F and
mdsio_write_field.F

* Update calls to S/R MDS_[READ/WRITE]_SEC_[X/Y]Z

To reflect the addition of 2 new arguments

* Update also commented out calls to MDS_WRITE_SEC_[X/Y]Z

* Document updating mdsio slice routines
  • Loading branch information
jm-c authored Aug 2, 2023
1 parent 2a22bb5 commit 5762277
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 195 deletions.
4 changes: 4 additions & 0 deletions doc/tag-index
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Notes on tags used in MITgcmUV
==============================

o pkg/mdsio:
- Add 2 new arguments (kLo & kHi) to pkg/mdsio Slice I/O routines that allow
to select which levels in Slice-array to read-in or to write-out to file.

checkpoint68r (2023/08/02)
o verification:
- adjust amplitude of perturbation (grdchk_eps) to improve Fwd/Adj gradient
Expand Down
72 changes: 36 additions & 36 deletions pkg/autodiff/active_file_control_slice.F
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ SUBROUTINE ACTIVE_READ_XZ_RL(
C Read the active variable from file.
CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_var, dummyRS,
I iRec, myThid )

Expand All @@ -124,7 +124,7 @@ SUBROUTINE ACTIVE_READ_XZ_RL(
CALL ADD_PREFIX( adpref, activeVar_file, adfname )
CALL MDS_WRITE_SEC_XZ(
I adfname, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_data_t, dummyRS,
I iRec, myOptimIter, myThid )

Expand All @@ -137,7 +137,7 @@ SUBROUTINE ACTIVE_READ_XZ_RL(

CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_data_t, dummyRS,
I iRec, myThid )

Expand All @@ -157,7 +157,7 @@ SUBROUTINE ACTIVE_READ_XZ_RL(
w_globFile = .FALSE.
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, w_globFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_data_t, dummyRS,
I iRec, myOptimIter, myThid )

Expand All @@ -179,7 +179,7 @@ SUBROUTINE ACTIVE_READ_XZ_RL(
C Read the active variable from file.
CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_var, dummyRS,
I iRec, myThid )
ENDIF
Expand Down Expand Up @@ -270,7 +270,7 @@ SUBROUTINE ACTIVE_READ_XZ_RS(
C Read the active variable from file.
CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_var,
I iRec, myThid )

Expand All @@ -292,7 +292,7 @@ SUBROUTINE ACTIVE_READ_XZ_RS(
CALL ADD_PREFIX( adpref, activeVar_file, adfname )
CALL MDS_WRITE_SEC_XZ(
I adfname, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_data_t,
I iRec, myOptimIter, myThid )

Expand All @@ -305,7 +305,7 @@ SUBROUTINE ACTIVE_READ_XZ_RS(

CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_data_t,
I iRec, myThid )

Expand All @@ -325,7 +325,7 @@ SUBROUTINE ACTIVE_READ_XZ_RS(
w_globFile = .FALSE.
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, w_globFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_data_t,
I iRec, myOptimIter, myThid )

Expand All @@ -347,7 +347,7 @@ SUBROUTINE ACTIVE_READ_XZ_RS(
C Read the active variable from file.
CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_var,
I iRec, myThid )
ENDIF
Expand Down Expand Up @@ -437,7 +437,7 @@ SUBROUTINE ACTIVE_READ_YZ_RL(
C Read the active variable from file.
CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_var, dummyRS,
I iRec, myThid )

Expand All @@ -459,7 +459,7 @@ SUBROUTINE ACTIVE_READ_YZ_RL(
CALL ADD_PREFIX( adpref, activeVar_file, adfname )
CALL MDS_WRITE_SEC_YZ(
I adfname, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_data_t, dummyRS,
I iRec, myOptimIter, myThid )

Expand All @@ -472,7 +472,7 @@ SUBROUTINE ACTIVE_READ_YZ_RL(

CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_data_t, dummyRS,
I iRec, myThid )

Expand All @@ -492,7 +492,7 @@ SUBROUTINE ACTIVE_READ_YZ_RL(
w_globFile = .FALSE.
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, w_globFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_data_t, dummyRS,
I iRec, myOptimIter, myThid )

Expand All @@ -514,7 +514,7 @@ SUBROUTINE ACTIVE_READ_YZ_RL(
C Read the active variable from file.
CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_var, dummyRS,
I iRec, myThid )
ENDIF
Expand Down Expand Up @@ -605,7 +605,7 @@ SUBROUTINE ACTIVE_READ_YZ_RS(
C Read the active variable from file.
CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_var,
I iRec, myThid )

Expand All @@ -627,7 +627,7 @@ SUBROUTINE ACTIVE_READ_YZ_RS(
CALL ADD_PREFIX( adpref, activeVar_file, adfname )
CALL MDS_WRITE_SEC_YZ(
I adfname, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_data_t,
I iRec, myOptimIter, myThid )

Expand All @@ -640,7 +640,7 @@ SUBROUTINE ACTIVE_READ_YZ_RS(

CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_data_t,
I iRec, myThid )

Expand All @@ -660,7 +660,7 @@ SUBROUTINE ACTIVE_READ_YZ_RS(
w_globFile = .FALSE.
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, w_globFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_data_t,
I iRec, myOptimIter, myThid )

Expand All @@ -682,7 +682,7 @@ SUBROUTINE ACTIVE_READ_YZ_RS(
C Read the active variable from file.
CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_var,
I iRec, myThid )
ENDIF
Expand Down Expand Up @@ -761,7 +761,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RL(
IF (theSimulationMode .EQ. FORWARD_SIMULATION) THEN
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_var, dummyRS,
I iRec, myOptimIter, myThid )
ENDIF
Expand All @@ -771,7 +771,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RL(

CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_data_t, dummyRS,
I iRec, myThid )

Expand All @@ -789,7 +789,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RL(
ENDDO
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_data_t, dummyRS,
I iRec, myOptimIter, myThid )

Expand All @@ -799,7 +799,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RL(
IF (theSimulationMode .EQ. TANGENT_SIMULATION) THEN
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_var, dummyRS,
I iRec, myOptimIter, myThid )
ENDIF
Expand Down Expand Up @@ -878,7 +878,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RS(
IF (theSimulationMode .EQ. FORWARD_SIMULATION) THEN
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_var,
I iRec, myOptimIter, myThid )
ENDIF
Expand All @@ -888,7 +888,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RS(

CALL MDS_READ_SEC_XZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_data_t,
I iRec, myThid )

Expand All @@ -906,7 +906,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RS(
ENDDO
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_data_t,
I iRec, myOptimIter, myThid )

Expand All @@ -916,7 +916,7 @@ SUBROUTINE ACTIVE_WRITE_XZ_RS(
IF (theSimulationMode .EQ. TANGENT_SIMULATION) THEN
CALL MDS_WRITE_SEC_XZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_var,
I iRec, myOptimIter, myThid )
ENDIF
Expand Down Expand Up @@ -995,7 +995,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RL(
IF (theSimulationMode .EQ. FORWARD_SIMULATION) THEN
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_var, dummyRS,
I iRec, myOptimIter, myThid )
ENDIF
Expand All @@ -1005,7 +1005,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RL(

CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
O active_data_t, dummyRS,
I iRec, myThid )

Expand All @@ -1023,7 +1023,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RL(
ENDDO
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_data_t, dummyRS,
I iRec, myOptimIter, myThid )

Expand All @@ -1033,7 +1033,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RL(
IF (theSimulationMode .EQ. TANGENT_SIMULATION) THEN
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RL', myNr,
I 'RL', myNr, 1, myNr,
I active_var, dummyRS,
I iRec, myOptimIter, myThid )
ENDIF
Expand Down Expand Up @@ -1112,7 +1112,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RS(
IF (theSimulationMode .EQ. FORWARD_SIMULATION) THEN
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_var,
I iRec, myOptimIter, myThid )
ENDIF
Expand All @@ -1122,7 +1122,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RS(

CALL MDS_READ_SEC_YZ(
I activeVar_file, prec, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
O dummyRL, active_data_t,
I iRec, myThid )

Expand All @@ -1140,7 +1140,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RS(
ENDDO
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_data_t,
I iRec, myOptimIter, myThid )

Expand All @@ -1150,7 +1150,7 @@ SUBROUTINE ACTIVE_WRITE_YZ_RS(
IF (theSimulationMode .EQ. TANGENT_SIMULATION) THEN
CALL MDS_WRITE_SEC_YZ(
I activeVar_file, prec, globalFile, useCurrentDir,
I 'RS', myNr,
I 'RS', myNr, 1, myNr,
I dummyRL, active_var,
I iRec, myOptimIter, myThid )
ENDIF
Expand Down
8 changes: 4 additions & 4 deletions pkg/ctrl/ctrl_set_globfld_xz.F
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ SUBROUTINE ctrl_set_globfld_xz(
C In this call, value "False" is passed to 3rd arg "globalFile"
C and value "False" is passed to 4th arg "useCurrentDir,"
c CALL MDS_WRITE_SEC_XZ( fname, ctrlprec, .FALSE., .FALSE.,
c I 'RL', Nr, globfldxz, dummyRS,
c I 'RL', Nr, 1, Nr, globfldxz, dummyRS,
c I irec, optimcycle, myThid )

C-- The only difference here (vs initial MDSWRITEFIELDXZ call) is that,
C in WRITE_REC_XZ_RL, argument "globalFile" is not set to false but
C instead is taken from global setting "globalFiles" ;
C But this might be more consistent with call to WRITE_REC_3D_RL above
C in WRITE_REC_XZ_RL, argument "globalFile" is not set to FALSE but is
C instead taken from RD_WR_SEC common block (but currently set to FALSE
C in ini_model_io.F if using OBCS)
CALL WRITE_REC_XZ_RL( fname, ctrlprec,
I Nr, globfldxz,
I irec, optimcycle, myThid )
Expand Down
10 changes: 5 additions & 5 deletions pkg/ctrl/ctrl_set_globfld_yz.F
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ SUBROUTINE ctrl_set_globfld_yz(
ENDDO

DO irec = nrec_nl*Nx+1, ncvarrecs(ivartype)
C-- Call directly MDS_WRITE_SEC_yZ (instead of indirectly via MDSWRITEFIELDyZ)
C-- Call directly MDS_WRITE_SEC_YZ (instead of indirectly via MDSWRITEFIELDYZ)
C --> expect zero difference.
C In this call, value "False" is passed to 3rd arg "globalFile"
C and value "False" is passed to 4th arg "useCurrentDir,"
c CALL MDS_WRITE_SEC_YZ( fname, ctrlprec, .FALSE., .FALSE.,
c I 'RL', Nr, globfldyz, dummyRS,
c I 'RL', Nr, 1, Nr, globfldyz, dummyRS,
c I irec, optimcycle, myThid )

C-- The only difference here (vs initial MDSWRITEFIELDYZ call) is that,
C in WRITE_REC_YZ_RL, argument "globalFile" is not set to false but
C instead is taken from global setting "globalFiles" ;
C But this might be more consistent with call to WRITE_REC_3D_RL above
C in WRITE_REC_YZ_RL, argument "globalFile" is not set to FALSE but is
C instead taken from RD_WR_SEC common block (but currently set to FALSE
C in ini_model_io.F if using OBCS)
CALL WRITE_REC_YZ_RL( fname, ctrlprec,
I Nr, globfldyz,
I irec, optimcycle, myThid )
Expand Down
Loading

0 comments on commit 5762277

Please sign in to comment.