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.
Changeset 3364 for branches/2012/dev_r3322_NOCS09_SAS/NEMOGCM/NEMO/SAS_SRC/sbcssm.F90 – NEMO

Ignore:
Timestamp:
2012-04-24T15:52:15+02:00 (12 years ago)
Author:
sga
Message:

NEMO branch dev_r3322_NOCS09_SAS: tinkering to get initialisation to happen in the right order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2012/dev_r3322_NOCS09_SAS/NEMOGCM/NEMO/SAS_SRC/sbcssm.F90

    r3363 r3364  
    3333   PRIVATE 
    3434 
    35    PUBLIC   sbc_ssm_sas_init   ! called by opa.F90 
    36    PUBLIC   sbc_ssm            ! called by step.F90 
     35   PUBLIC   sbc_ssm_init   ! called by sbc_init 
     36   PUBLIC   sbc_ssm        ! called by sbc 
    3737 
    3838   CHARACTER(len=100)   ::   cn_dir     = './'    !: Root directory for location of ssm files 
     
    8282      ! 
    8383      IF( nn_timing == 1 )  CALL timing_start( 'sbc_ssm') 
    84       ! 
    85       IF( kt == nit000 ) THEN 
    86          ! 
    87          !! switch off stuff that isn't sensible with a standalone module 
    88          !! do it here rather than in sbc_ssm_init so that we don't have to rely on the order 
    89          !! init routines are called in nemogcm 
    90          !! note that we still need sbc_ssm called first in sbc 
    91          ! 
    92          IF( ln_cpl ) THEN  
    93             IF( lwp ) WRITE(numout,*) 'Coupled mode not sensible with StandAlone Surface scheme' 
    94             ln_cpl = .FALSE. 
    95          ENDIF 
    96          IF( ln_apr_dyn ) THEN 
    97             IF( lwp ) WRITE(numout,*) 'No atmospheric gradient needed with StandAlone Surface scheme' 
    98             ln_apr_dyn = .FALSE. 
    99          ENDIF 
    100          IF( ln_dm2dc ) THEN 
    101             IF( lwp ) WRITE(numout,*) 'No diurnal cycle needed with StandAlone Surface scheme' 
    102             ln_dm2dc = .FALSE. 
    103          ENDIF 
    104          IF( ln_rnf ) THEN 
    105             IF( lwp ) WRITE(numout,*) 'No runoff needed with StandAlone Surface scheme' 
    106             ln_rnf = .FALSE. 
    107          ENDIF 
    108          IF( ln_ssr ) THEN 
    109             IF( lwp ) WRITE(numout,*) 'No surface relaxation needed with StandAlone Surface scheme' 
    110             ln_ssr = .FALSE. 
    111          ENDIF 
    112          IF( nn_fwb > 0 ) THEN 
    113             IF( lwp ) WRITE(numout,*) 'No freshwater budget adjustment needed with StandAlone Surface scheme' 
    114             nn_fwb = 0 
    115          ENDIF 
    116          IF( nn_closea > 0 ) THEN       
    117             IF( lwp ) WRITE(numout,*) 'No closed seas adjustment needed with StandAlone Surface scheme' 
    118             nn_closea = 0   
    119          ENDIF 
    120       ENDIF 
    12184 
    12285      IF( nfld_3d > 0 ) CALL fld_read( kt, 1, sf_ssm_3d )      !==   read data at kt time step   ==! 
     
    153116 
    154117 
    155    SUBROUTINE sbc_ssm_sas_init 
     118   SUBROUTINE sbc_ssm_init 
    156119      !!---------------------------------------------------------------------- 
    157120      !!                  ***  ROUTINE sbc_ssm_init  *** 
     
    166129      INTEGER  :: inum, idv, idimv, jpm              ! local integer 
    167130      !! 
    168       CHARACTER(len=100)               ::  cn_dir       ! Root directory for location of core files 
    169       TYPE(FLD_N), DIMENSION(jpfld_3d) ::  slf_3d       ! array of namelist information on the fields to read 
    170       TYPE(FLD_N), DIMENSION(jpfld_2d) ::  slf_2d       ! array of namelist information on the fields to read 
     131      CHARACTER(len=100)                     ::  cn_dir       ! Root directory for location of core files 
     132      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::  slf_3d       ! array of namelist information on the fields to read 
     133      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::  slf_2d       ! array of namelist information on the fields to read 
    171134      TYPE(FLD_N) :: sn_tem, sn_sal                     ! information about the fields to be read 
    172135      TYPE(FLD_N) :: sn_usp, sn_vsp, sn_ssh 
    173136      ! 
    174       NAMELIST/namsbc_ssm_sas/cn_dir, ln_3d_uv, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh 
     137      NAMELIST/namsbc_ssm/cn_dir, ln_3d_uv, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh 
    175138 
    176139      !!---------------------------------------------------------------------- 
     
    188151      ! 
    189152      REWIND( numnam )                          ! read in namlist namsbc_ssm 
    190       READ  ( numnam, namsbc_ssm_sas ) 
     153      READ  ( numnam, namsbc_ssm ) 
    191154      !                                         ! store namelist information in an array 
    192155      !                                         ! Control print 
    193156      IF(lwp) THEN 
    194157         WRITE(numout,*) 
    195          WRITE(numout,*) 'sbc_ssm_sas : standalone surface scheme ' 
     158         WRITE(numout,*) 'sbc_ssm : standalone surface scheme ' 
    196159         WRITE(numout,*) '~~~~~~~~~~~ ' 
    197          WRITE(numout,*) '   Namelist namsbc_ssm_sas' 
     160         WRITE(numout,*) '   Namelist namsbc_ssm' 
    198161         WRITE(numout,*) 
    199162      ENDIF 
     163       
     164      ! 
     165      !! switch off stuff that isn't sensible with a standalone module 
     166      !! note that we need sbc_ssm called first in sbc 
     167      ! 
     168      IF( ln_cpl ) THEN 
     169         IF( lwp ) WRITE(numout,*) 'Coupled mode not sensible with StandAlone Surface scheme' 
     170         ln_cpl = .FALSE. 
     171      ENDIF 
     172      IF( ln_apr_dyn ) THEN 
     173         IF( lwp ) WRITE(numout,*) 'No atmospheric gradient needed with StandAlone Surface scheme' 
     174         ln_apr_dyn = .FALSE. 
     175      ENDIF 
     176      IF( ln_dm2dc ) THEN 
     177         IF( lwp ) WRITE(numout,*) 'No diurnal cycle needed with StandAlone Surface scheme' 
     178         ln_dm2dc = .FALSE. 
     179      ENDIF 
     180      IF( ln_rnf ) THEN 
     181         IF( lwp ) WRITE(numout,*) 'No runoff needed with StandAlone Surface scheme' 
     182         ln_rnf = .FALSE. 
     183      ENDIF 
     184      IF( ln_ssr ) THEN 
     185         IF( lwp ) WRITE(numout,*) 'No surface relaxation needed with StandAlone Surface scheme' 
     186         ln_ssr = .FALSE. 
     187      ENDIF 
     188      IF( nn_fwb > 0 ) THEN 
     189         IF( lwp ) WRITE(numout,*) 'No freshwater budget adjustment needed with StandAlone Surface scheme' 
     190         nn_fwb = 0 
     191      ENDIF 
     192      IF( nn_closea > 0 ) THEN 
     193         IF( lwp ) WRITE(numout,*) 'No closed seas adjustment needed with StandAlone Surface scheme' 
     194         nn_closea = 0 
     195      ENDIF 
     196 
    200197      !  
     198      !! following code is a bit messy, but distinguishes between when u,v are 3d arrays and 
     199      !! when we have other 3d arrays that we need to read in 
     200      !! so if a new field is added i.e. jf_new, just give it the next integer in sequence 
     201      !! for the corresponding dimension (currently if ln_3d_uv is true, 4 for 2d and 3 for 3d, 
     202      !! alternatively if ln_3d_uv is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d, 
     203      !! and the rest of the logic should still work 
     204      ! 
    201205      jf_tem = 1 ; jf_sal = 2 ; jf_ssh = 3 
    202206      ! 
     
    205209         nfld_3d  = 2 
    206210         nfld_2d  = 3 
    207          slf_3d(jf_usp) = sn_usp ; slf_3d(jf_vsp) = sn_vsp 
    208211      ELSE 
    209212         jf_usp = 4 ; jf_vsp = 5 
    210213         nfld_3d  = 0 
    211214         nfld_2d  = 5 
    212          slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp 
    213       ENDIF 
    214  
    215       slf_2d(jf_tem) = sn_tem ; slf_2d(jf_sal) = sn_sal ; slf_2d(jf_ssh) = sn_ssh 
     215      ENDIF 
     216 
     217      IF( nfld_3d > 0 ) THEN 
     218         ALLOCATE( slf_3d(nfld_3d), STAT=ierr )         ! set slf structure 
     219         IF( ierr > 0 ) THEN 
     220            CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 3d structure' )   ;   RETURN 
     221         ENDIF 
     222         IF( ln_3d_uv ) THEN 
     223            slf_3d(jf_usp) = sn_usp 
     224            slf_3d(jf_vsp) = sn_vsp 
     225         ENDIF 
     226      ENDIF 
     227 
     228      IF( nfld_2d > 0 ) THEN 
     229         ALLOCATE( slf_2d(nfld_2d), STAT=ierr )         ! set slf structure 
     230         IF( ierr > 0 ) THEN 
     231            CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 2d structure' )   ;   RETURN 
     232         ENDIF 
     233         slf_2d(jf_tem) = sn_tem ; slf_2d(jf_sal) = sn_sal ; slf_2d(jf_ssh) = sn_ssh 
     234         IF( .NOT. ln_3d_uv ) THEN 
     235            slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp 
     236         ENDIF 
     237      ENDIF 
    216238      ! 
    217239      IF( nfld_3d > 0 ) THEN 
    218240         ALLOCATE( sf_ssm_3d(nfld_3d), STAT=ierr )         ! set sf structure 
    219241         IF( ierr > 0 ) THEN 
    220             CALL ctl_stop( 'sbc_ssm: unable to allocate sf structure' )   ;   RETURN 
     242            CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf structure' )   ;   RETURN 
    221243         ENDIF 
    222244         DO ifpr = 1, nfld_3d 
     
    234256         ALLOCATE( sf_ssm_2d(nfld_2d), STAT=ierr )         ! set sf structure 
    235257         IF( ierr > 0 ) THEN 
    236             CALL ctl_stop( 'sbc_ssm: unable to allocate sf 2d structure' )   ;   RETURN 
     258            CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf 2d structure' )   ;   RETURN 
    237259         ENDIF 
    238260         DO ifpr = 1, nfld_2d 
     
    260282      ENDIF 
    261283      ! 
    262    END SUBROUTINE sbc_ssm_sas_init 
     284      ! finally tidy up 
     285 
     286      IF( nfld_3d > 0 ) DEALLOCATE( slf_3d, STAT=ierr ) 
     287      IF( nfld_2d > 0 ) DEALLOCATE( slf_2d, STAT=ierr ) 
     288      ! 
     289   END SUBROUTINE sbc_ssm_init 
    263290 
    264291   !!====================================================================== 
Note: See TracChangeset for help on using the changeset viewer.