C $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/ksnow/press_release/code_expt/Attic/shelfice_fields_load.F,v 1.2 2017/02/01 12:54:47 dgoldberg dead $ C $Name: $ #include "SHELFICE_OPTIONS.h" CStartOfInterface SUBROUTINE SHELFICE_FIELDS_LOAD( I myTime, myIter, myThid ) C *==========================================================* C | SUBROUTINE SHELFICE_LOAD C | o Control reading of SHELFICE fields from external source. C *==========================================================* IMPLICIT NONE C === Global variables === #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #include "GRID.h" #include "SHELFICE.h" C === Routine arguments === C myTime :: Simulation time C myIter :: Simulation timestep number C myThid :: Thread no. that called this routine. _RL myTime INTEGER myIter INTEGER myThid CEndOfInterface C === Functions === #ifdef ALLOW_SHELFICE C === Local variables === C bi,bj, i,j :: Loop counters C tYear :: Fraction within year of myTime C mnthIndex :: Current time in whole months C prevMnthIndex C fNam :: Strings used in constructing file names C mnthNam C loadNewData :: true when need to load new data from file INTEGER bi,bj,i,j c _RL pfact LOGICAL first, changed C-- for use with useMMsurfFc: CHARACTER*(MAX_LEN_FNAM) fNam INTEGER nm0, nm1, nmP _RL myRelTime, fac, tmpFac C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| C-- find which month to use for surface BC C aim_surfForc_TimePeriod :: Length of forcing time period (e.g. 1 month) C aim_surfForc_NppCycle :: Number of time period per Cycle (e.g. 12) myRelTime = myTime - startTime first = (myRelTime .lt. 0.5*deltaTClock) if ( shelfice_forcing_period .eq. 0.D0 ) THEN ! & .or. externForcingCycle .eq. 0.D0 ) then C control parameter is constant in time and only needs to be updated C once in the beginning changed = .false. nm0 = 1 nm1 = 1 fac = 1.D0 else C-- Now calculate whether it is time to update the forcing arrays if (externForcingCycle .eq. 0.0 ) THEN CALL GET_PERIODIC_INTERVAL( O nmP, nm0, nm1, tmpFac, fac, I externForcingCycle, shelfice_forcing_period, I deltaTclock, I myTime+0.5*shelfice_forcing_period, I myThid ) fac = 1.D0 - fac else CALL GET_PERIODIC_INTERVAL( O nmP, nm0, nm1, tmpFac, fac, I externForcingCycle, shelfice_forcing_period, I deltaTclock, myTime, I myThid ) endif IF ( nm0.NE.nmP ) THEN changed = .true. ELSE changed = .false. ENDIF IF ( first ) changed = .false. endif C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| C- Load new data: C- Only one thread updates parameter in common block C- Wait for everyone to set loadNewData before Master updates prevMnthIndex _BARRIER IF ( first ) THEN IF ( SHELFICEmassforcingfile .NE. ' ' ) THEN CALL READ_REC_XY_RL(SHELFICEmassforcingfile, & SHELFICEmass1, & nm0,myIter,myThid) ENDIF ! PRINT *, "GOT HERE FIELDS LOAD 2" C- endif 1rst iter. ENDIF IF ( first .OR. changed) THEN DO bj=myByLo(myThid),myByHi(myThid) DO bi=myBxLo(myThid),myBxHi(myThid) DO j=1,sNy DO i=1,sNx SHELFICEmass0(i,j,bi,bj) = & SHELFICEmass1(i,j,bi,bj) ENDDO ENDDO ENDDO ENDDO ! PRINT *, "GOT HERE FIELDS LOAD 4" IF ( SHELFICEmassforcingfile .NE. ' ' ) THEN CALL READ_REC_XY_RL(SHELFICEmassforcingfile, & SHELFICEmass1, & nm0,myIter,myThid) ENDIF C- endif 1rst iter. ENDIF DO bj=myByLo(myThid),myByHi(myThid) DO bi=myBxLo(myThid),myBxHi(myThid) DO j=1,sNy DO i=1,sNx shelficemass (i,j,bi,bj) = & fac * shelficemass0(i,j,bi,bj) & + (1-fac) * shelficemass1(i,j,bi,bj) ENDDO ENDDO ENDDO ENDDO CALL EXCH_XY_RL (shelficemass, myThid) ! print *, "GOT HERE STREAMICE FIELDS LOAD", ! & first,changed,nm0,nm1,fac #endif RETURN END