New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
sbcssm.F90 in branches/2013/dev_r3853_CNRS9_ConfSetting/NEMOGCM/NEMO/SAS_SRC – NEMO

source: branches/2013/dev_r3853_CNRS9_ConfSetting/NEMOGCM/NEMO/SAS_SRC/sbcssm.F90 @ 3901

Last change on this file since 3901 was 3901, checked in by clevy, 11 years ago

Configuration Setting/Step2, see ticket:#1074

File size: 13.3 KB
Line 
1MODULE sbcssm
2   !!======================================================================
3   !!                       ***  MODULE  sbcssm  ***
4   !! Off-line : interpolation of the physical fields
5   !!======================================================================
6   !! History :
7   !!   NEMO         3.4  ! 2012-03 First version by S. Alderson
8   !!                     !         Heavily derived from Christian's dtadyn routine
9   !!                     !         in OFF_SRC
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   sbc_ssm_init : initialization, namelist read, and SAVEs control
14   !!   sbc_ssm      : Interpolation of the fields
15   !!----------------------------------------------------------------------
16   USE oce             ! ocean dynamics and tracers variables
17   USE c1d             ! 1D configuration: lk_c1d
18   USE dom_oce         ! ocean domain: variables
19   USE zdf_oce         ! ocean vertical physics: variables
20   USE sbc_oce         ! surface module: variables
21   USE phycst          ! physical constants
22   USE eosbn2          ! equation of state - Brunt Vaisala frequency
23   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
24   USE zpshde          ! z-coord. with partial steps: horizontal derivatives
25   USE in_out_manager  ! I/O manager
26   USE iom             ! I/O library
27   USE lib_mpp         ! distributed memory computing library
28   USE prtctl          ! print control
29   USE fldread         ! read input fields
30   USE timing          ! Timing
31
32   IMPLICIT NONE
33   PRIVATE
34
35   PUBLIC   sbc_ssm_init   ! called by sbc_init
36   PUBLIC   sbc_ssm        ! called by sbc
37
38   CHARACTER(len=100)   ::   cn_dir         !: Root directory for location of ssm files
39   LOGICAL              ::   ln_3d_uv       !: specify whether input velocity data is 3D
40   INTEGER  , SAVE      ::   nfld_3d
41   INTEGER  , SAVE      ::   nfld_2d
42
43   INTEGER  , PARAMETER ::   jpfld_3d = 4   ! maximum number of files to read
44   INTEGER  , PARAMETER ::   jpfld_2d = 1   ! maximum number of files to read
45   INTEGER  , SAVE      ::   jf_tem         ! index of temperature
46   INTEGER  , SAVE      ::   jf_sal         ! index of salinity
47   INTEGER  , SAVE      ::   jf_usp         ! index of u velocity component
48   INTEGER  , SAVE      ::   jf_vsp         ! index of v velocity component
49   INTEGER  , SAVE      ::   jf_ssh         ! index of sea surface height
50
51   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_3d  ! structure of input fields (file information, fields read)
52   TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_2d  ! structure of input fields (file information, fields read)
53
54   !! * Substitutions
55#  include "domzgr_substitute.h90"
56#  include "vectopt_loop_substitute.h90"
57   !!----------------------------------------------------------------------
58   !! NEMO/OFF 3.3 , NEMO Consortium (2010)
59   !! $Id: sbcssm.F90 3294 2012-01-28 16:44:18Z rblod $
60   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
61   !!----------------------------------------------------------------------
62CONTAINS
63
64   SUBROUTINE sbc_ssm( kt )
65      !!----------------------------------------------------------------------
66      !!                  ***  ROUTINE sbc_ssm  ***
67      !!
68      !! ** Purpose :  Prepares dynamics and physics fields from a NEMO run
69      !!               for an off-line simulation using surface processes only
70      !!
71      !! ** Method : calculates the position of data
72      !!             - interpolates data if needed
73      !!----------------------------------------------------------------------
74      !
75      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
76      !
77      INTEGER  ::   ji, jj     ! dummy loop indices
78      REAL(wp) ::   ztinta     ! ratio applied to after  records when doing time interpolation
79      REAL(wp) ::   ztintb     ! ratio applied to before records when doing time interpolation
80      !!----------------------------------------------------------------------
81     
82      !
83      IF( nn_timing == 1 )  CALL timing_start( 'sbc_ssm')
84
85      IF( nfld_3d > 0 ) CALL fld_read( kt, 1, sf_ssm_3d )      !==   read data at kt time step   ==!
86      IF( nfld_2d > 0 ) CALL fld_read( kt, 1, sf_ssm_2d )      !==   read data at kt time step   ==!
87      !
88      IF( ln_3d_uv ) THEN
89         ssu_m(:,:) = sf_ssm_3d(jf_usp)%fnow(:,:,1) * umask(:,:,1)    ! u-velocity
90         ssv_m(:,:) = sf_ssm_3d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1)    ! v-velocity
91      ELSE
92         ssu_m(:,:) = sf_ssm_2d(jf_usp)%fnow(:,:,1) * umask(:,:,1)    ! u-velocity
93         ssv_m(:,:) = sf_ssm_2d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1)    ! v-velocity
94      ENDIF
95      !
96      sst_m(:,:) = sf_ssm_2d(jf_tem)%fnow(:,:,1) * tmask(:,:,1)    ! temperature
97      sss_m(:,:) = sf_ssm_2d(jf_sal)%fnow(:,:,1) * tmask(:,:,1)    ! salinity
98      ssh_m(:,:) = sf_ssm_2d(jf_ssh)%fnow(:,:,1) * tmask(:,:,1)    ! sea surface height
99      !
100      tsn(:,:,1,jp_tem) = sst_m(:,:)
101      tsn(:,:,1,jp_sal) = sss_m(:,:)
102      ub (:,:,1       ) = ssu_m(:,:)
103      vb (:,:,1       ) = ssv_m(:,:)
104
105      IF(ln_ctl) THEN                  ! print control
106         CALL prt_ctl(tab2d_1=sst_m, clinfo1=' sst_m   - : ', mask1=tmask, ovlap=1   )
107         CALL prt_ctl(tab2d_1=sss_m, clinfo1=' sss_m   - : ', mask1=tmask, ovlap=1   )
108         CALL prt_ctl(tab2d_1=ssu_m, clinfo1=' ssu_m   - : ', mask1=umask, ovlap=1   )
109         CALL prt_ctl(tab2d_1=ssv_m, clinfo1=' ssv_m   - : ', mask1=vmask, ovlap=1   )
110         CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' ssh_m   - : ', mask1=tmask, ovlap=1   )
111      ENDIF
112      !
113      IF( nn_timing == 1 )  CALL timing_stop( 'sbc_ssm')
114      !
115   END SUBROUTINE sbc_ssm
116
117
118   SUBROUTINE sbc_ssm_init
119      !!----------------------------------------------------------------------
120      !!                  ***  ROUTINE sbc_ssm_init  ***
121      !!
122      !! ** Purpose :   Initialisation of the dynamical data     
123      !! ** Method  : - read the data namsbc_ssm namelist
124      !!
125      !! ** Action  : - read parameters
126      !!----------------------------------------------------------------------
127      INTEGER  :: ierr, ierr0, ierr1, ierr2, ierr3   ! return error code
128      INTEGER  :: ifpr                               ! dummy loop indice
129      INTEGER  :: inum, idv, idimv, jpm              ! local integer
130      INTEGER  :: ios                                ! Local integer output status for namelist read
131      !!
132      CHARACTER(len=100)                     ::  cn_dir       ! Root directory for location of core files
133      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::  slf_3d       ! array of namelist information on the fields to read
134      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::  slf_2d       ! array of namelist information on the fields to read
135      TYPE(FLD_N) :: sn_tem, sn_sal                     ! information about the fields to be read
136      TYPE(FLD_N) :: sn_usp, sn_vsp, sn_ssh
137      !
138      NAMELIST/namsbc_ssm/cn_dir, ln_3d_uv, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh
139
140      !!----------------------------------------------------------------------
141      !                                   ! ============
142      !                                   !   Namelist
143      !                                   ! ============
144      !
145      REWIND( numnam_ref )              ! Namelist namsbc_ssm in reference namelist : SAS files for dynamical data
146      READ  ( numnam_ref, namsbc_ssm, IOSTAT = ios, ERR = 901)
147901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssm in reference namelist', lwp )
148
149      REWIND( numnam_cfg )              ! Namelist namsbc_ssm in configuration namelist : SAS files for dynamical data
150      READ  ( numnam_cfg, namsbc_ssm, IOSTAT = ios, ERR = 902 )
151902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssm in configuration namelist', lwp )
152      WRITE ( numond, namsbc_ssm )
153      !                                         ! store namelist information in an array
154      !                                         ! Control print
155      IF(lwp) THEN
156         WRITE(numout,*)
157         WRITE(numout,*) 'sbc_ssm : standalone surface scheme '
158         WRITE(numout,*) '~~~~~~~~~~~ '
159         WRITE(numout,*) '   Namelist namsbc_ssm'
160         WRITE(numout,*)
161      ENDIF
162     
163      !
164      !! switch off stuff that isn't sensible with a standalone module
165      !! note that we need sbc_ssm called first in sbc
166      !
167      IF( ln_cpl ) THEN
168         IF( lwp ) WRITE(numout,*) 'Coupled mode not sensible with StandAlone Surface scheme'
169         ln_cpl = .FALSE.
170      ENDIF
171      IF( ln_apr_dyn ) THEN
172         IF( lwp ) WRITE(numout,*) 'No atmospheric gradient needed with StandAlone Surface scheme'
173         ln_apr_dyn = .FALSE.
174      ENDIF
175      IF( ln_dm2dc ) THEN
176         IF( lwp ) WRITE(numout,*) 'No diurnal cycle needed with StandAlone Surface scheme'
177         ln_dm2dc = .FALSE.
178      ENDIF
179      IF( ln_rnf ) THEN
180         IF( lwp ) WRITE(numout,*) 'No runoff needed with StandAlone Surface scheme'
181         ln_rnf = .FALSE.
182      ENDIF
183      IF( ln_ssr ) THEN
184         IF( lwp ) WRITE(numout,*) 'No surface relaxation needed with StandAlone Surface scheme'
185         ln_ssr = .FALSE.
186      ENDIF
187      IF( nn_fwb > 0 ) THEN
188         IF( lwp ) WRITE(numout,*) 'No freshwater budget adjustment needed with StandAlone Surface scheme'
189         nn_fwb = 0
190      ENDIF
191      IF( nn_closea > 0 ) THEN
192         IF( lwp ) WRITE(numout,*) 'No closed seas adjustment needed with StandAlone Surface scheme'
193         nn_closea = 0
194      ENDIF
195
196      !
197      !! following code is a bit messy, but distinguishes between when u,v are 3d arrays and
198      !! when we have other 3d arrays that we need to read in
199      !! so if a new field is added i.e. jf_new, just give it the next integer in sequence
200      !! for the corresponding dimension (currently if ln_3d_uv is true, 4 for 2d and 3 for 3d,
201      !! alternatively if ln_3d_uv is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d,
202      !! and the rest of the logic should still work
203      !
204      jf_tem = 1 ; jf_sal = 2 ; jf_ssh = 3
205      !
206      IF( ln_3d_uv ) THEN
207         jf_usp = 1 ; jf_vsp = 2
208         nfld_3d  = 2
209         nfld_2d  = 3
210      ELSE
211         jf_usp = 4 ; jf_vsp = 5
212         nfld_3d  = 0
213         nfld_2d  = 5
214      ENDIF
215
216      IF( nfld_3d > 0 ) THEN
217         ALLOCATE( slf_3d(nfld_3d), STAT=ierr )         ! set slf structure
218         IF( ierr > 0 ) THEN
219            CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 3d structure' )   ;   RETURN
220         ENDIF
221         IF( ln_3d_uv ) THEN
222            slf_3d(jf_usp) = sn_usp
223            slf_3d(jf_vsp) = sn_vsp
224         ENDIF
225      ENDIF
226
227      IF( nfld_2d > 0 ) THEN
228         ALLOCATE( slf_2d(nfld_2d), STAT=ierr )         ! set slf structure
229         IF( ierr > 0 ) THEN
230            CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 2d structure' )   ;   RETURN
231         ENDIF
232         slf_2d(jf_tem) = sn_tem ; slf_2d(jf_sal) = sn_sal ; slf_2d(jf_ssh) = sn_ssh
233         IF( .NOT. ln_3d_uv ) THEN
234            slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp
235         ENDIF
236      ENDIF
237      !
238      IF( nfld_3d > 0 ) THEN
239         ALLOCATE( sf_ssm_3d(nfld_3d), STAT=ierr )         ! set sf structure
240         IF( ierr > 0 ) THEN
241            CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf structure' )   ;   RETURN
242         ENDIF
243         DO ifpr = 1, nfld_3d
244                                       ALLOCATE( sf_ssm_3d(ifpr)%fnow(jpi,jpj,jpk)    , STAT=ierr0 )
245            IF( slf_3d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_3d(ifpr)%fdta(jpi,jpj,jpk,2)  , STAT=ierr1 )
246            IF( ierr0 + ierr1 > 0 ) THEN
247               CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_3d array structure' )   ;   RETURN
248            ENDIF
249         END DO
250         !                                         ! fill sf with slf_i and control print
251         CALL fld_fill( sf_ssm_3d, slf_3d, cn_dir, 'sbc_ssm_init', '3D Data in file', 'namsbc_ssm' )
252      ENDIF
253
254      IF( nfld_2d > 0 ) THEN
255         ALLOCATE( sf_ssm_2d(nfld_2d), STAT=ierr )         ! set sf structure
256         IF( ierr > 0 ) THEN
257            CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf 2d structure' )   ;   RETURN
258         ENDIF
259         DO ifpr = 1, nfld_2d
260                                       ALLOCATE( sf_ssm_2d(ifpr)%fnow(jpi,jpj,1)    , STAT=ierr0 )
261            IF( slf_2d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_2d(ifpr)%fdta(jpi,jpj,1,2)  , STAT=ierr1 )
262            IF( ierr0 + ierr1 > 0 ) THEN
263               CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_2d array structure' )   ;   RETURN
264            ENDIF
265         END DO
266         !
267         CALL fld_fill( sf_ssm_2d, slf_2d, cn_dir, 'sbc_ssm_init', '2D Data in file', 'namsbc_ssm' )
268      ENDIF
269      !
270      ! lim code currently uses surface temperature and salinity in tsn array for initialisation
271      ! and ub, vb arrays in ice dynamics
272      ! so allocate enough of arrays to use
273      !
274      jpm = MAX(jp_tem, jp_sal)
275      ALLOCATE( tsn(jpi,jpj,1,jpm), STAT=ierr0 )
276      ALLOCATE( ub(jpi,jpj,1)     , STAT=ierr1 )
277      ALLOCATE( vb(jpi,jpj,1)     , STAT=ierr2 )
278      ierr = ierr0 + ierr1 + ierr2
279      IF( ierr > 0 ) THEN
280         CALL ctl_stop('sbc_ssm_init: unable to allocate surface arrays')
281      ENDIF
282      !
283      ! finally tidy up
284
285      IF( nfld_3d > 0 ) DEALLOCATE( slf_3d, STAT=ierr )
286      IF( nfld_2d > 0 ) DEALLOCATE( slf_2d, STAT=ierr )
287      !
288   END SUBROUTINE sbc_ssm_init
289
290   !!======================================================================
291END MODULE sbcssm
Note: See TracBrowser for help on using the repository browser.