123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- MODULE sbcssm
- !!======================================================================
- !! *** MODULE sbcssm ***
- !! Off-line : interpolation of the physical fields
- !!======================================================================
- !! History :
- !! NEMO 3.4 ! 2012-03 First version by S. Alderson
- !! ! Heavily derived from Christian's dtadyn routine
- !! ! in OFF_SRC
- !!----------------------------------------------------------------------
- !!----------------------------------------------------------------------
- !! sbc_ssm_init : initialization, namelist read, and SAVEs control
- !! sbc_ssm : Interpolation of the fields
- !!----------------------------------------------------------------------
- USE oce ! ocean dynamics and tracers variables
- USE c1d ! 1D configuration: lk_c1d
- USE dom_oce ! ocean domain: variables
- USE zdf_oce ! ocean vertical physics: variables
- USE sbc_oce ! surface module: variables
- USE phycst ! physical constants
- USE eosbn2 ! equation of state - Brunt Vaisala frequency
- USE lbclnk ! ocean lateral boundary conditions (or mpp link)
- USE zpshde ! z-coord. with partial steps: horizontal derivatives
- USE in_out_manager ! I/O manager
- USE iom ! I/O library
- USE lib_mpp ! distributed memory computing library
- USE prtctl ! print control
- USE fldread ! read input fields
- USE timing ! Timing
- IMPLICIT NONE
- PRIVATE
- PUBLIC sbc_ssm_init ! called by sbc_init
- PUBLIC sbc_ssm ! called by sbc
- CHARACTER(len=100) :: cn_dir !: Root directory for location of ssm files
- LOGICAL :: ln_3d_uve !: specify whether input velocity data is 3D
- LOGICAL :: ln_read_frq !: specify whether we must read frq or not
- LOGICAL :: l_initdone = .false.
- INTEGER :: nfld_3d
- INTEGER :: nfld_2d
- INTEGER :: jf_tem ! index of temperature
- INTEGER :: jf_sal ! index of salinity
- INTEGER :: jf_usp ! index of u velocity component
- INTEGER :: jf_vsp ! index of v velocity component
- INTEGER :: jf_ssh ! index of sea surface height
- INTEGER :: jf_e3t ! index of first T level thickness
- INTEGER :: jf_frq ! index of fraction of qsr absorbed in the 1st T level
- TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_3d ! structure of input fields (file information, fields read)
- TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_2d ! structure of input fields (file information, fields read)
- !!----------------------------------------------------------------------
- !! NEMO/OFF 3.3 , NEMO Consortium (2010)
- !! $Id: sbcssm.F90 2442 2015-06-12 08:32:11Z ufla $
- !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
- !!----------------------------------------------------------------------
- CONTAINS
- SUBROUTINE sbc_ssm( kt )
- !!----------------------------------------------------------------------
- !! *** ROUTINE sbc_ssm ***
- !!
- !! ** Purpose : Prepares dynamics and physics fields from a NEMO run
- !! for an off-line simulation using surface processes only
- !!
- !! ** Method : calculates the position of data
- !! - interpolates data if needed
- !!----------------------------------------------------------------------
- !
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !
- INTEGER :: ji, jj ! dummy loop indices
- REAL(wp) :: ztinta ! ratio applied to after records when doing time interpolation
- REAL(wp) :: ztintb ! ratio applied to before records when doing time interpolation
- !!----------------------------------------------------------------------
-
- !
- IF( nn_timing == 1 ) CALL timing_start( 'sbc_ssm')
- IF( nfld_3d > 0 ) CALL fld_read( kt, 1, sf_ssm_3d ) !== read data at kt time step ==!
- IF( nfld_2d > 0 ) CALL fld_read( kt, 1, sf_ssm_2d ) !== read data at kt time step ==!
- !
- IF( ln_3d_uve ) THEN
- ssu_m(:,:) = sf_ssm_3d(jf_usp)%fnow(:,:,1) * umask(:,:,1) ! u-velocity
- ssv_m(:,:) = sf_ssm_3d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1) ! v-velocity
- IF( lk_vvl ) e3t_m(:,:) = sf_ssm_3d(jf_e3t)%fnow(:,:,1) * tmask(:,:,1) ! v-velocity
- ELSE
- ssu_m(:,:) = sf_ssm_2d(jf_usp)%fnow(:,:,1) * umask(:,:,1) ! u-velocity
- ssv_m(:,:) = sf_ssm_2d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1) ! v-velocity
- IF( lk_vvl ) e3t_m(:,:) = sf_ssm_2d(jf_e3t)%fnow(:,:,1) * tmask(:,:,1) ! v-velocity
- ENDIF
- !
- sst_m(:,:) = sf_ssm_2d(jf_tem)%fnow(:,:,1) * tmask(:,:,1) ! temperature
- sss_m(:,:) = sf_ssm_2d(jf_sal)%fnow(:,:,1) * tmask(:,:,1) ! salinity
- ssh_m(:,:) = sf_ssm_2d(jf_ssh)%fnow(:,:,1) * tmask(:,:,1) ! sea surface height
- IF( ln_read_frq ) frq_m(:,:) = sf_ssm_2d(jf_frq)%fnow(:,:,1) * tmask(:,:,1) ! sea surface height
- !
- IF ( nn_ice == 1 ) THEN
- tsn(:,:,1,jp_tem) = sst_m(:,:)
- tsn(:,:,1,jp_sal) = sss_m(:,:)
- tsb(:,:,1,jp_tem) = sst_m(:,:)
- tsb(:,:,1,jp_sal) = sss_m(:,:)
- ENDIF
- ub (:,:,1) = ssu_m(:,:)
- vb (:,:,1) = ssv_m(:,:)
- IF(ln_ctl) THEN ! print control
- CALL prt_ctl(tab2d_1=sst_m, clinfo1=' sst_m - : ', mask1=tmask, ovlap=1 )
- CALL prt_ctl(tab2d_1=sss_m, clinfo1=' sss_m - : ', mask1=tmask, ovlap=1 )
- CALL prt_ctl(tab2d_1=ssu_m, clinfo1=' ssu_m - : ', mask1=umask, ovlap=1 )
- CALL prt_ctl(tab2d_1=ssv_m, clinfo1=' ssv_m - : ', mask1=vmask, ovlap=1 )
- CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' ssh_m - : ', mask1=tmask, ovlap=1 )
- IF( lk_vvl ) CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' e3t_m - : ', mask1=tmask, ovlap=1 )
- IF( ln_read_frq ) CALL prt_ctl(tab2d_1=frq_m, clinfo1=' frq_m - : ', mask1=tmask, ovlap=1 )
- ENDIF
- !
- IF( l_initdone ) THEN ! Mean value at each nn_fsbc time-step !
- CALL iom_put( 'ssu_m', ssu_m )
- CALL iom_put( 'ssv_m', ssv_m )
- CALL iom_put( 'sst_m', sst_m )
- CALL iom_put( 'sss_m', sss_m )
- CALL iom_put( 'ssh_m', ssh_m )
- IF( lk_vvl ) CALL iom_put( 'e3t_m', e3t_m )
- IF( ln_read_frq ) CALL iom_put( 'frq_m', frq_m )
- ENDIF
- !
- IF( nn_timing == 1 ) CALL timing_stop( 'sbc_ssm')
- !
- END SUBROUTINE sbc_ssm
- SUBROUTINE sbc_ssm_init
- !!----------------------------------------------------------------------
- !! *** ROUTINE sbc_ssm_init ***
- !!
- !! ** Purpose : Initialisation of the dynamical data
- !! ** Method : - read the data namsbc_ssm namelist
- !!
- !! ** Action : - read parameters
- !!----------------------------------------------------------------------
- INTEGER :: ierr, ierr0, ierr1, ierr2, ierr3 ! return error code
- INTEGER :: ifpr ! dummy loop indice
- INTEGER :: inum, idv, idimv, jpm ! local integer
- INTEGER :: ios ! Local integer output status for namelist read
- !!
- CHARACTER(len=100) :: cn_dir ! Root directory for location of core files
- TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_3d ! array of namelist information on the fields to read
- TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_2d ! array of namelist information on the fields to read
- TYPE(FLD_N) :: sn_tem, sn_sal ! information about the fields to be read
- TYPE(FLD_N) :: sn_usp, sn_vsp
- TYPE(FLD_N) :: sn_ssh, sn_e3t, sn_frq
- !
- NAMELIST/namsbc_sas/cn_dir, ln_3d_uve, ln_read_frq, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh, sn_e3t, sn_frq
- !!----------------------------------------------------------------------
-
- IF( ln_rstart .AND. nn_components == jp_iam_sas ) RETURN
-
- REWIND( numnam_ref ) ! Namelist namsbc_sas in reference namelist : Input fields
- READ ( numnam_ref, namsbc_sas, IOSTAT = ios, ERR = 901)
- 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_sas in reference namelist', lwp )
- REWIND( numnam_cfg ) ! Namelist namsbc_sas in configuration namelist : Input fields
- READ ( numnam_cfg, namsbc_sas, IOSTAT = ios, ERR = 902 )
- 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_sas in configuration namelist', lwp )
- IF(lwm) WRITE ( numond, namsbc_sas )
- ! ! store namelist information in an array
- ! ! Control print
- IF(lwp) THEN
- WRITE(numout,*)
- WRITE(numout,*) 'sbc_sas : standalone surface scheme '
- WRITE(numout,*) '~~~~~~~~~~~ '
- WRITE(numout,*) ' Namelist namsbc_sas'
- WRITE(numout,*) ' Are we supplying a 3D u,v and e3 field ln_3d_uve = ', ln_3d_uve
- WRITE(numout,*) ' Are we reading frq (fraction of qsr absorbed in the 1st T level) ln_read_frq = ', ln_read_frq
- WRITE(numout,*)
- ENDIF
- !
- !! switch off stuff that isn't sensible with a standalone module
- !! note that we need sbc_ssm called first in sbc
- !
- IF( ln_apr_dyn ) THEN
- IF( lwp ) WRITE(numout,*) 'No atmospheric gradient needed with StandAlone Surface scheme'
- ln_apr_dyn = .FALSE.
- ENDIF
- IF( ln_rnf ) THEN
- IF( lwp ) WRITE(numout,*) 'No runoff needed with StandAlone Surface scheme'
- ln_rnf = .FALSE.
- ENDIF
- IF( ln_ssr ) THEN
- IF( lwp ) WRITE(numout,*) 'No surface relaxation needed with StandAlone Surface scheme'
- ln_ssr = .FALSE.
- ENDIF
- IF( nn_fwb > 0 ) THEN
- IF( lwp ) WRITE(numout,*) 'No freshwater budget adjustment needed with StandAlone Surface scheme'
- nn_fwb = 0
- ENDIF
- IF( nn_closea > 0 ) THEN
- IF( lwp ) WRITE(numout,*) 'No closed seas adjustment needed with StandAlone Surface scheme'
- nn_closea = 0
- ENDIF
- !
- !! following code is a bit messy, but distinguishes between when u,v are 3d arrays and
- !! when we have other 3d arrays that we need to read in
- !! so if a new field is added i.e. jf_new, just give it the next integer in sequence
- !! for the corresponding dimension (currently if ln_3d_uve is true, 4 for 2d and 3 for 3d,
- !! alternatively if ln_3d_uve is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d,
- !! and the rest of the logic should still work
- !
- jf_tem = 1 ; jf_sal = 2 ; jf_ssh = 3 ; jf_frq = 4 ! default 2D fields index
- !
- IF( ln_3d_uve ) THEN
- jf_usp = 1 ; jf_vsp = 2 ; jf_e3t = 3 ! define 3D fields index
- nfld_3d = 2 + COUNT( (/lk_vvl/) ) ! number of 3D fields to read
- nfld_2d = 3 + COUNT( (/ln_read_frq/) ) ! number of 2D fields to read
- ELSE
- jf_usp = 4 ; jf_vsp = 5 ; jf_e3t = 6 ; jf_frq = 6 + COUNT( (/lk_vvl/) ) ! update 2D fields index
- nfld_3d = 0 ! no 3D fields to read
- nfld_2d = 5 + COUNT( (/lk_vvl/) ) + COUNT( (/ln_read_frq/) ) ! number of 2D fields to read
- ENDIF
- IF( nfld_3d > 0 ) THEN
- ALLOCATE( slf_3d(nfld_3d), STAT=ierr ) ! set slf structure
- IF( ierr > 0 ) THEN
- CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 3d structure' ) ; RETURN
- ENDIF
- slf_3d(jf_usp) = sn_usp
- slf_3d(jf_vsp) = sn_vsp
- IF( lk_vvl ) slf_3d(jf_e3t) = sn_e3t
- ENDIF
- IF( nfld_2d > 0 ) THEN
- ALLOCATE( slf_2d(nfld_2d), STAT=ierr ) ! set slf structure
- IF( ierr > 0 ) THEN
- CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 2d structure' ) ; RETURN
- ENDIF
- slf_2d(jf_tem) = sn_tem ; slf_2d(jf_sal) = sn_sal ; slf_2d(jf_ssh) = sn_ssh
- IF( ln_read_frq ) slf_2d(jf_frq) = sn_frq
- IF( .NOT. ln_3d_uve ) THEN
- slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp
- IF( lk_vvl ) slf_2d(jf_e3t) = sn_e3t
- ENDIF
- ENDIF
- !
- ierr1 = 0 ! default definition if slf_?d(ifpr)%ln_tint = .false.
- IF( nfld_3d > 0 ) THEN
- ALLOCATE( sf_ssm_3d(nfld_3d), STAT=ierr ) ! set sf structure
- IF( ierr > 0 ) THEN
- CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf structure' ) ; RETURN
- ENDIF
- DO ifpr = 1, nfld_3d
- ALLOCATE( sf_ssm_3d(ifpr)%fnow(jpi,jpj,jpk) , STAT=ierr0 )
- IF( slf_3d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_3d(ifpr)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 )
- IF( ierr0 + ierr1 > 0 ) THEN
- CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_3d array structure' ) ; RETURN
- ENDIF
- END DO
- ! ! fill sf with slf_i and control print
- CALL fld_fill( sf_ssm_3d, slf_3d, cn_dir, 'sbc_ssm_init', '3D Data in file', 'namsbc_ssm' )
- ENDIF
- IF( nfld_2d > 0 ) THEN
- ALLOCATE( sf_ssm_2d(nfld_2d), STAT=ierr ) ! set sf structure
- IF( ierr > 0 ) THEN
- CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf 2d structure' ) ; RETURN
- ENDIF
- DO ifpr = 1, nfld_2d
- ALLOCATE( sf_ssm_2d(ifpr)%fnow(jpi,jpj,1) , STAT=ierr0 )
- IF( slf_2d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_2d(ifpr)%fdta(jpi,jpj,1,2) , STAT=ierr1 )
- IF( ierr0 + ierr1 > 0 ) THEN
- CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_2d array structure' ) ; RETURN
- ENDIF
- END DO
- !
- CALL fld_fill( sf_ssm_2d, slf_2d, cn_dir, 'sbc_ssm_init', '2D Data in file', 'namsbc_ssm' )
- ENDIF
- !
- ! finally tidy up
- IF( nfld_3d > 0 ) DEALLOCATE( slf_3d, STAT=ierr )
- IF( nfld_2d > 0 ) DEALLOCATE( slf_2d, STAT=ierr )
- CALL sbc_ssm( nit000 ) ! need to define ss?_m arrays used in limistate
- IF( .NOT. ln_read_frq ) frq_m(:,:) = 1.
- l_initdone = .TRUE.
- !
- END SUBROUTINE sbc_ssm_init
- !!======================================================================
- END MODULE sbcssm
|