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 12249 for NEMO/branches/2019/dev_r11943_MERGE_2019/tests/STATION_ASF/MY_SRC/diawri.F90 – NEMO

Ignore:
Timestamp:
2019-12-13T19:48:00+01:00 (4 years ago)
Author:
laurent
Message:

Made STATION_ASF testcase fully compliant with new timestepping scheme.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11943_MERGE_2019/tests/STATION_ASF/MY_SRC/diawri.F90

    r11831 r12249  
    2525   !!   dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields 
    2626   !!---------------------------------------------------------------------- 
    27    USE oce            ! ocean dynamics and tracers  
     27   USE oce            ! ocean dynamics and tracers 
    2828   USE dom_oce        ! ocean space and time domain 
    2929   USE phycst         ! physical constants 
     
    3333   USE lbclnk         ! ocean lateral boundary conditions (or mpp link) 
    3434   USE in_out_manager ! I/O manager 
    35    USE iom            !  
    36    USE ioipsl         !  
     35   USE iom            ! 
     36   USE ioipsl         ! 
    3737#if defined key_si3 
    38    USE ice  
    39    USE icewri  
     38   USE ice 
     39   USE icewri 
    4040#endif 
    4141   USE lib_mpp         ! MPP library 
     
    7474   END FUNCTION dia_wri_alloc 
    7575 
    76     
    77    SUBROUTINE dia_wri( kt ) 
     76 
     77   SUBROUTINE dia_wri( kt, Kmm ) 
    7878      !!--------------------------------------------------------------------- 
    7979      !!                  ***  ROUTINE dia_wri  *** 
    80       !!                    
    81       !! ** Purpose :   Standard output of opa: dynamics and tracer fields  
    82       !!      NETCDF format is used by default  
    83       !!      Standalone surface scheme  
     80      !! 
     81      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
     82      !!      NETCDF format is used by default 
     83      !!     STATION_ASF 
    8484      !! 
    8585      !! ** Method  :  use iom_put 
    8686      !!---------------------------------------------------------------------- 
    8787      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index 
    88       !!---------------------------------------------------------------------- 
    89       !  
     88      INTEGER, INTENT( in ) ::   Kmm     ! ocean time level index 
     89      !!---------------------------------------------------------------------- 
     90      ! 
     91      IF( ln_timing )   CALL timing_start('dia_wri') 
     92      ! 
    9093      ! Output the initial state and forcings 
    91       IF( ninist == 1 ) THEN                        
    92          CALL dia_wri_state( 'output.init' ) 
     94      IF( ninist == 1 ) THEN 
     95         CALL dia_wri_state( Kmm, 'output.init' ) 
    9396         ninist = 0 
    9497      ENDIF 
     
    99102      CALL iom_put(  "ssu", ssu_m(:,:) )    ! ocean surface current along i-axis 
    100103      CALL iom_put(  "ssv", ssv_m(:,:) )    ! ocean surface current along j-axis 
     104      ! 
     105      IF( ln_timing )   CALL timing_stop('dia_wri') 
    101106      ! 
    102107   END SUBROUTINE dia_wri 
     
    115120         &      ndex_hU(jpi*jpj) , ndex_U(jpi*jpj*jpk) ,     & 
    116121         &      ndex_hV(jpi*jpj) , ndex_V(jpi*jpj*jpk) , STAT=ierr(1) ) 
    117          ! 
     122      ! 
    118123      dia_wri_alloc = MAXVAL(ierr) 
    119124      CALL mpp_sum( 'diawri', dia_wri_alloc ) 
     
    121126   END FUNCTION dia_wri_alloc 
    122127 
    123     
    124    SUBROUTINE dia_wri( kt ) 
     128 
     129 
     130   SUBROUTINE dia_wri( kt, Kmm ) 
    125131      !!--------------------------------------------------------------------- 
    126132      !!                  ***  ROUTINE dia_wri  *** 
    127       !!                    
    128       !! ** Purpose :   Standard output of opa: dynamics and tracer fields  
    129       !!      NETCDF format is used by default  
    130       !! 
    131       !! ** Method  :   At the beginning of the first time step (nit000),  
     133      !! 
     134      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
     135      !!      NETCDF format is used by default 
     136      !! 
     137      !! ** Method  :   At the beginning of the first time step (nit000), 
    132138      !!      define all the NETCDF files and fields 
    133139      !!      At each time step call histdef to compute the mean if ncessary 
    134       !!      Each nwrite time step, output the instantaneous or mean fields 
     140      !!      Each nn_write time step, output the instantaneous or mean fields 
    135141      !!---------------------------------------------------------------------- 
    136142      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index 
     143      INTEGER, INTENT( in ) ::   Kmm  ! ocean time level index 
    137144      ! 
    138145      LOGICAL ::   ll_print = .FALSE.                        ! =T print and flush numout 
     
    144151      REAL(wp) ::   zsto, zout, zmax, zjulian                ! local scalars 
    145152      !!---------------------------------------------------------------------- 
    146       !  
     153      ! 
     154      IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==! 
     155         CALL dia_wri_state( Kmm, 'output.init' ) 
     156         ninist = 0 
     157      ENDIF 
     158      ! 
     159      IF( nn_write == -1 )   RETURN   ! we will never do any output 
     160      ! 
    147161      IF( ln_timing )   CALL timing_start('dia_wri') 
    148       ! 
    149       IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==! 
    150          CALL dia_wri_state( 'output.init' ) 
    151          ninist = 0 
    152       ENDIF 
    153162      ! 
    154163      ! 0. Initialisation 
     
    159168 
    160169      ! Define frequency of output and means 
    161       IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!) 
    162       ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time) 
    163       ENDIF 
     170      clop = "x"         ! no use of the mask value (require less cpu time and otherwise the model crashes) 
    164171#if defined key_diainstant 
    165       zsto = nwrite * rdt 
     172      zsto = nn_write * rdt 
    166173      clop = "inst("//TRIM(clop)//")" 
    167174#else 
     
    169176      clop = "ave("//TRIM(clop)//")" 
    170177#endif 
    171       zout = nwrite * rdt 
     178      zout = nn_write * rdt 
    172179      zmax = ( nitend - nit000 + 1 ) * rdt 
    173180 
     
    196203            &                    ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian 
    197204         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,   & 
    198                                  ' limit storage in depth = ', ipk 
     205            ' limit storage in depth = ', ipk 
    199206 
    200207         ! WRITE root name in date.file for use by postpro 
    201208         IF(lwp) THEN 
    202             CALL dia_nam( clhstnam, nwrite,' ' ) 
     209            CALL dia_nam( clhstnam, nn_write,' ' ) 
    203210            CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
    204211            WRITE(inum,*) clhstnam 
     
    208215         ! Define the T grid FILE ( nid_T ) 
    209216 
    210          CALL dia_nam( clhstnam, nwrite, 'grid_T' ) 
     217         CALL dia_nam( clhstnam, nn_write, 'grid_T' ) 
    211218         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename 
    212219         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit 
     
    220227         ! Define the U grid FILE ( nid_U ) 
    221228 
    222          CALL dia_nam( clhstnam, nwrite, 'grid_U' ) 
     229         CALL dia_nam( clhstnam, nn_write, 'grid_U' ) 
    223230         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename 
    224231         CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu 
     
    232239         ! Define the V grid FILE ( nid_V ) 
    233240 
    234          CALL dia_nam( clhstnam, nwrite, 'grid_V' )                   ! filename 
     241         CALL dia_nam( clhstnam, nn_write, 'grid_V' )                   ! filename 
    235242         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam 
    236243         CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv 
     
    254261            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) 
    255262         CALL histdef( nid_T, "sosfldow", "downward salt flux"                 , "PSU/m2/s",  &  ! (sfx) 
    256              &         jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) 
     263            &         jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) 
    257264         CALL histdef( nid_T, "sohefldo", "Net Downward Heat Flux"             , "W/m2"   ,   &  ! qns + qsr 
    258265            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout ) 
     
    291298      ! --------------------- 
    292299 
    293       ! ndex(1) est utilise ssi l'avant dernier argument est different de  
     300      ! ndex(1) est utilise ssi l'avant dernier argument est different de 
    294301      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument 
    295302      ! donne le nombre d'elements, et ndex la liste des indices a sortir 
    296303 
    297       IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN  
     304      IF( lwp .AND. MOD( itmod, nn_write ) == 0 ) THEN 
    298305         WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step' 
    299306         WRITE(numout,*) '~~~~~~ ' 
     
    304311      CALL histwrite( nid_T, "sss_m", it, sss_m, ndim_hT, ndex_hT )   ! sea surface salinity 
    305312      CALL histwrite( nid_T, "sowaflup", it, (emp - rnf )  , ndim_hT, ndex_hT )   ! upward water flux 
    306       CALL histwrite( nid_T, "sosfldow", it, sfx           , ndim_hT, ndex_hT )   ! downward salt flux  
    307                                                                                   ! (includes virtual salt flux beneath ice  
    308                                                                                   ! in linear free surface case) 
     313      CALL histwrite( nid_T, "sosfldow", it, sfx           , ndim_hT, ndex_hT )   ! downward salt flux 
     314      ! (includes virtual salt flux beneath ice 
     315      ! in linear free surface case) 
    309316 
    310317      CALL histwrite( nid_T, "sohefldo", it, qns + qsr     , ndim_hT, ndex_hT )   ! total heat flux 
    311318      CALL histwrite( nid_T, "soshfldo", it, qsr           , ndim_hT, ndex_hT )   ! solar heat flux 
    312       CALL histwrite( nid_T, "soicecov", it, fr_i          , ndim_hT, ndex_hT )   ! ice fraction    
    313       CALL histwrite( nid_T, "sowindsp", it, wndm          , ndim_hT, ndex_hT )   ! wind speed    
    314  
    315          ! Write fields on U grid 
     319      CALL histwrite( nid_T, "soicecov", it, fr_i          , ndim_hT, ndex_hT )   ! ice fraction 
     320      CALL histwrite( nid_T, "sowindsp", it, wndm          , ndim_hT, ndex_hT )   ! wind speed 
     321 
     322      ! Write fields on U grid 
    316323      CALL histwrite( nid_U, "ssu_m"   , it, ssu_m         , ndim_hU, ndex_hU )   ! i-current speed 
    317324      CALL histwrite( nid_U, "sozotaux", it, utau          , ndim_hU, ndex_hU )   ! i-wind stress 
    318325 
    319          ! Write fields on V grid 
     326      ! Write fields on V grid 
    320327      CALL histwrite( nid_V, "ssv_m"   , it, ssv_m         , ndim_hV, ndex_hV )   ! j-current speed 
    321328      CALL histwrite( nid_V, "sometauy", it, vtau          , ndim_hV, ndex_hV )   ! j-wind stress 
     
    334341#endif 
    335342 
    336    SUBROUTINE dia_wri_state( cdfile_name ) 
     343   SUBROUTINE dia_wri_state( Kmm, cdfile_name ) 
    337344      !!--------------------------------------------------------------------- 
    338345      !!                 ***  ROUTINE dia_wri_state  *** 
    339       !!         
    340       !! ** Purpose :   create a NetCDF file named cdfile_name which contains  
     346      !! 
     347      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
    341348      !!      the instantaneous ocean state and forcing fields. 
    342349      !!        Used to find errors in the initial state or save the last 
     
    347354      !!      File 'output.abort.nc' is created in case of abnormal job end 
    348355      !!---------------------------------------------------------------------- 
     356      INTEGER           , INTENT( in ) ::   Kmm              ! time level index 
    349357      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created 
    350358      !! 
    351359      INTEGER :: inum 
    352360      !!---------------------------------------------------------------------- 
    353       !  
     361      ! 
    354362      IF(lwp) WRITE(numout,*) 
    355363      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state' 
     
    358366 
    359367#if defined key_si3 
    360      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl ) 
     368      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl ) 
    361369#else 
    362      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. ) 
    363 #endif 
    364  
    365       CALL iom_rstput( 0, 0, inum, 'votemper', tsn(:,:,:,jp_tem) )    ! now temperature 
    366       CALL iom_rstput( 0, 0, inum, 'vosaline', tsn(:,:,:,jp_sal) )    ! now salinity 
    367       CALL iom_rstput( 0, 0, inum, 'sossheig', sshn              )    ! sea surface height 
    368       CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity 
    369       CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity 
    370       CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity 
     370      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. ) 
     371#endif 
     372 
     373      CALL iom_rstput( 0, 0, inum, 'votemper', ts(:,:,:,jp_tem,Kmm) )    ! now temperature 
     374      CALL iom_rstput( 0, 0, inum, 'vosaline', ts(:,:,:,jp_sal,Kmm) )    ! now salinity 
     375      CALL iom_rstput( 0, 0, inum, 'sossheig', ssh(:,:,Kmm)              )    ! sea surface height 
     376      CALL iom_rstput( 0, 0, inum, 'vozocrtx', uu(:,:,:,Kmm)                )    ! now i-velocity 
     377      CALL iom_rstput( 0, 0, inum, 'vomecrty', vv(:,:,:,Kmm)                )    ! now j-velocity 
     378         CALL iom_rstput( 0, 0, inum, 'vovecrtz', ww             )    ! now k-velocity 
    371379      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget 
    372380      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux 
     
    375383      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress 
    376384      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress 
    377   
     385 
    378386#if defined key_si3 
    379387      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid 
     
    383391      ! 
    384392      CALL iom_close( inum ) 
    385       !  
     393      ! 
    386394   END SUBROUTINE dia_wri_state 
    387395 
Note: See TracChangeset for help on using the changeset viewer.