C $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/sciascia/rbcs/rbcs_readparms.F,v 1.1 2012/08/08 01:57:14 heimbach Exp $ C $Name: $ #include "RBCS_OPTIONS.h" CBOP C !ROUTINE: RBCS_READPARMS C !INTERFACE: ========================================================== SUBROUTINE RBCS_READPARMS( myThid ) C !DESCRIPTION: C Initialize RBCS parameters, read in data.rbcs C !USES: =============================================================== IMPLICIT NONE #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #ifdef ALLOW_PTRACERS #include "PTRACERS_SIZE.h" #endif #include "RBCS_SIZE.h" #include "RBCS_PARAMS.h" C !INPUT PARAMETERS: =================================================== C myThid :: my thread Id. number INTEGER myThid C !OUTPUT PARAMETERS: ================================================== C none #ifdef ALLOW_RBCS C === Local variables === C msgBuf :: Informational/error message buffer C iUnit :: Work variable for IO unit number CHARACTER*(MAX_LEN_MBUF) msgBuf INTEGER iUnit INTEGER irbc INTEGER ium,ivm,iwm #ifdef ALLOW_PTRACERS INTEGER iTracer #endif C-- useRBCptracers is no longer used LOGICAL useRBCptracers CEOP C-- RBCS parameters: NAMELIST /RBCS_PARM01/ & tauRelaxU, & tauRelaxV, & tauRelaxT, & tauRelaxS, & relaxMaskUFile, & relaxMaskVFile, & relaxMaskFile, & relaxUFile, & relaxVFile, & relaxTFile, & relaxSFile, & useRBCuVel, & useRBCvVel, & useRBCtemp, & useRBCsalt, & useRBCptracers, & rbcsIniter, & rbcsForcingPeriod, & rbcsForcingCycle, & rbcsForcingOffset, & rbcsForcingUPeriod, & rbcsForcingUCycle, & rbcsForcingUOffset, & rbcsForcingVPeriod, & rbcsForcingVCycle, & rbcsForcingVOffset, #ifdef ALLOW_NONHYDROSTATIC & tauRelaxW, & relaxMaskWFile, & relaxWFile, & useRBCwVel, & rbcsForcingWPeriod, & rbcsForcingWCycle, & rbcsForcingWOffset, #endif & rbcsVanishingTime, & rbcsSingleTimeFiles, & deltaTrbcs, & rbcsIter0 #ifdef ALLOW_PTRACERS NAMELIST /RBCS_PARM02/ & useRBCptrnum, tauRelaxPTR, & relaxPtracerFile #endif C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| _BEGIN_MASTER(myThid) C-- Default values DO ium=1,UmLEN useRBCuVel(ium) =.FALSE. tauRelaxU(ium) = 0. relaxMaskUFile(ium) = ' ' relaxUFile = ' ' rbcsForcingUPeriod(ium) = 0. _d 0 rbcsForcingUCycle(ium) = 0. _d 0 rbcsForcingUOffset(ium) = 0. _d 0 ENDDO DO ivm=1,VmLEN useRBCvVel(ivm) =.FALSE. tauRelaxV(ivm) = 0. relaxMaskVFile = ' ' relaxVFile = ' ' rbcsForcingVPeriod(ivm) = 0. _d 0 rbcsForcingVCycle(ivm) = 0. _d 0 rbcsForcingVOffset(ivm) = 0. _d 0 ENDDO #ifdef ALLOW_NONHYDROSTATIC DO iwm=1,WmLEN useRBCwVel(iwm) =.FALSE. tauRelaxW(iwm) = 0. relaxMaskWFile(iwm) = ' ' relaxWFile = ' ' rbcsForcingWPeriod(iwm) = 0. _d 0 rbcsForcingWCycle(iwm) = 0. _d 0 rbcsForcingWOffset(iwm) = 0. _d 0 ENDDO #endif tauRelaxT = 0. tauRelaxS = 0. useRBCtemp =.FALSE. useRBCsalt =.FALSE. DO irbc=1,maskLEN relaxMaskFile(irbc) = ' ' ENDDO relaxTFile = ' ' relaxSFile = ' ' rbcsIniter = 0 rbcsForcingPeriod = 0. _d 0 rbcsForcingCycle = 0. _d 0 rbcsForcingOffset = 0. _d 0 rbcsVanishingTime = 0. _d 0 rbcsSingleTimeFiles = .FALSE. deltaTrbcs = deltaTclock rbcsIter0 = 0 #ifdef ALLOW_PTRACERS DO iTracer=1,PTRACERS_num useRBCptrnum(iTracer)=.FALSE. tauRelaxPTR(iTracer) = 0. relaxPtracerFile(iTracer) = ' ' ENDDO #endif useRBCptracers=.FALSE. C-- Open and read the data.rbcs file WRITE(msgBuf,'(A)') ' RBCS_READPARMS: opening data.rbcs' CALL PRINT_MESSAGE(msgBuf, standardMessageUnit, & SQUEEZE_RIGHT , 1) CALL OPEN_COPY_DATA_FILE( I 'data.rbcs', 'RBCS_READPARMS', O iUnit, I myThid ) READ(UNIT=iUnit,NML=RBCS_PARM01) #ifdef ALLOW_PTRACERS READ(UNIT=iUnit,NML=RBCS_PARM02) #endif WRITE(msgBuf,'(A)') & ' RBCS_READPARMS: finished reading data.rbcs' CALL PRINT_MESSAGE(msgBuf, standardMessageUnit, & SQUEEZE_RIGHT , 1) C-- Close the open data file CLOSE(iUnit) C--- Check RBCS config and params: #ifdef DISABLE_RBCS_MOM DO ium=1,UmLEN IF ( useRBCuVel(ium)) THEN WRITE(msgBuf,'(2A,2(L2,A))') 'RBCS_READPARMS: ', & 'cannot use RBC for U & (useRBCuVel(ium)=',useRBCuVel(ium)')' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ', & 'when DISABLE_RBCS_MOM & is defined (in RBCS_OPTIONS.h)' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDDO DO ivm=1,VmLEN IF ( useRBCvVel(ivm)) THEN WRITE(msgBuf,'(2A,2(L2,A))') 'RBCS_READPARMS: ', & 'cannot use RBC for V & (useRBCvVel(ivm)=',useRBCvVel(ivm)')' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)') 'RBCS_READPARMS:', & 'when DISABLE_RBCS_MOM & is defined (in RBCS_OPTIONS.h)' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDDO #ifdef ALLOW_NONHYDROSTATIC DO iwm=1,WmLEN IF ( useRBCvVel(iwm)) THEN WRITE(msgBuf,'(2A,2(L2,A))') 'RBCS_READPARMS: ', & 'cannot use RBC for W & (useRBCwVel(iwm)=',useRBCwVel(iwm)')' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)') 'RBCS_READPARMS:', & 'when DISABLE_RBCS_MOM & is defined (in RBCS_OPTIONS.h)' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDDO #endif #endif /* DISABLE_RBCS_MOM */ IF (rbcsIniter.NE.0) THEN WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'rbcsIniter has been replaced by rbcsForcingOffset ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'which is in seconds. Please change your data.rbcs' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARAMS' ENDIF IF (startTime.LT.rbcsForcingOffset+0.5*rbcsForcingPeriod .AND. & .NOT. rbcsSingleTimeFiles) THEN IF (rbcsForcingCycle.GT.0) THEN WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingOffset & +0.5*rbcsForcingPeriod ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'will use last record' CALL PRINT_ERROR( msgBuf, myThid ) ELSE WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingOffset & +0.5*rbcsForcingPeriod ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'not allowed with rbcsForcingCycle=0 & unless rbcsSingleTimeFiles' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARAMS' ENDIF ENDIF DO ium=1,UmLEN IF (startTime.LT.rbcsForcingUOffset(ium) & +0.5*rbcsForcingUPeriod(ium) .AND. & .NOT. rbcsSingleTimeFiles) THEN IF (rbcsForcingUCycle(ium).GT.0) THEN WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingUOffset(ium) & +0.5*rbcsForcingUPeriod(ium) ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'will use last record' CALL PRINT_ERROR( msgBuf, myThid ) ELSE WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingUOffset(ium) & +0.5*rbcsForcingUPeriod(ium) ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'not allowed with rbcsForcingUCycle=0 & unless rbcsSingleTimeFiles' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARAMS' ENDIF ENDIF ENDDO DO ivm=1,VmLEN IF (startTime.LT.rbcsForcingVOffset(ivm) & +0.5*rbcsForcingVPeriod(ivm) .AND. & .NOT. rbcsSingleTimeFiles) THEN IF (rbcsForcingVCycle(ivm).GT.0) THEN WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingVOffset(ivm) & +0.5*rbcsForcingVPeriod(ivm) ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'will use last record' CALL PRINT_ERROR( msgBuf, myThid ) ELSE WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingVOffset(ivm) & +0.5*rbcsForcingVPeriod(ivm) ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'not allowed with rbcsForcingCycle=0 & unless rbcsSingleTimeFiles' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARAMS' ENDIF ENDIF ENDDO #ifdef ALLOW_NONHYDROSTATIC DO iwm=1,WmLEN IF (startTime.LT.rbcsForcingWOffset(iwm) & +0.5*rbcsForcingWPeriod(iwm) .AND. & .NOT. rbcsSingleTimeFiles) THEN IF (rbcsForcingWCycle(iwm).GT.0) THEN WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingWOffset(iwm) & +0.5*rbcsForcingWPeriod(iwm) ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'will use last record' CALL PRINT_ERROR( msgBuf, myThid ) ELSE WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'startTime before rbcsForcingWOffset(iwm) & +0.5*rbcsForcingWPeriod(iwm) ' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ', & 'not allowed with rbcsForcingCycle=0 & unless rbcsSingleTimeFiles' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARAMS' ENDIF ENDIF ENDDO #endif DO ium=1,UmLEN IF ( useRBCuVel(ium) .AND. tauRelaxU(ium).LE.0. ) THEN WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ', & 'tauRelaxU(ium) cannot be zero with useRBCuVel(ium)' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDDO DO ivm=1,VmLEN IF ( useRBCvVel(ivm) .AND. tauRelaxV(ivm).LE.0. ) THEN WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ', & 'tauRelaxV(ivm) cannot be zero with useRBCvVel(ivm)' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDDO #ifdef ALLOW_NONHYDROSTATIC DO iwm=1,WmLEN IF ( useRBCwVel(iwm) .AND. tauRelaxW(iwm).LE.0. ) THEN WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ', & 'tauRelaxW(iwm) cannot be zero with useRBCwVel(iwm)' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDDO #endif IF ( useRBCtemp .AND. tauRelaxT.LE.0. ) THEN WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ', & 'tauRelaxT cannot be zero with useRBCtemp' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF IF ( useRBCsalt .AND. tauRelaxS.LE.0. ) THEN WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ', & 'tauRelaxS cannot be zero with useRBCsalt' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF #ifdef ALLOW_PTRACERS DO iTracer=1,PTRACERS_num IF ( useRBCptrnum(iTracer) ) THEN IF ( .NOT.usePTRACERS ) THEN WRITE(msgBuf,'(2A,I6,A)') 'RBCS_READPARMS: ', & 'usePTRACERS=F => cannot use RBCS for tracer:', iTracer CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF c IF ( iTracer.GT.PTRACERS_numInUse ) THEN c STOP 'ABNORMAL END: S/R RBCS_READPARMS' c ENDIF IF ( tauRelaxPTR(iTracer).LE.0. ) THEN WRITE(msgBuf,'(2A,I6,A)') 'RBCS_READPARMS: ', & 'tauRelaxPTR(itr=', iTracer, ' ) = 0. is' CALL PRINT_ERROR( msgBuf, myThid ) WRITE(msgBuf,'(2A,I6,A)') 'RBCS_READPARMS: ', & 'not allowed with useRBCptr(itr)=T' CALL PRINT_ERROR( msgBuf, myThid ) STOP 'ABNORMAL END: S/R RBCS_READPARMS' ENDIF ENDIF ENDDO #endif _END_MASTER(myThid) C Everyone else must wait for the parameters to be loaded _BARRIER #endif /* ALLOW_RBCS */ RETURN END