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.
asmbal.F90 in branches/UKMO/dev_r5518_v3.4_asm_nemovar_community_bgc_ersem/NEMOGCM/NEMO/OPA_SRC/ASM – NEMO

source: branches/UKMO/dev_r5518_v3.4_asm_nemovar_community_bgc_ersem/NEMOGCM/NEMO/OPA_SRC/ASM/asmbal.F90 @ 7716

Last change on this file since 7716 was 7716, checked in by dford, 7 years ago

Tidy up and simplify use of arrays for logchl assimilation balancing.

File size: 5.8 KB
Line 
1MODULE asmbal
2   !!======================================================================
3   !!                       ***  MODULE asmbal  ***
4   !! Assimilation balancing interface: Write to file the balancing increments
5   !!                                   calculated for biogeochemistry
6   !!======================================================================
7   !!----------------------------------------------------------------------
8   !!   'key_asminc' : Switch on the assimilation increment interface
9   !!----------------------------------------------------------------------
10   !!   asm_bal_wri  : Write out the background state
11   !!----------------------------------------------------------------------
12   !! * Modules used
13   USE par_kind, ONLY: &   ! Precision variables
14      & wp
15   USE iom                 ! I/O module
16   USE asminc              ! Main assimilation increments module
17   USE asmpar              ! Parameters for the assimilation interface
18
19   IMPLICIT NONE
20
21   !! * Routine accessibility
22   PRIVATE
23   PUBLIC asm_bal_wri   !: Write out the background state
24
25CONTAINS
26
27   SUBROUTINE asm_bal_wri( kt )
28      !!-----------------------------------------------------------------------
29      !!
30      !!                  ***  ROUTINE asm_bal_wri ***
31      !!
32      !! ** Purpose : Write to file the balancing increments
33      !!              calculated for biogeochemistry
34      !!
35      !! ** Method  : Write to file the balancing increments
36      !!              calculated for biogeochemistry
37      !!
38      !! ** Action  :
39      !!                   
40      !! References :
41      !!
42      !! History    :
43      !!        ! 2014-08 (D. Ford)  Initial version, based on asm_bkg_wri
44      !!-----------------------------------------------------------------------
45      !! * Arguments
46      INTEGER, INTENT( IN ) :: kt        ! Current time-step
47      !! * Local declarations
48      CHARACTER(LEN=50) :: cl_asmbal     ! Filename (with extension)
49      LOGICAL           :: llok          ! Check if file exists
50      INTEGER           :: inum          ! File unit number
51      REAL(wp)          :: zdate         ! Date
52      !!-----------------------------------------------------------------------
53     
54      ! Set things up
55      zdate = REAL( ndastp )
56      WRITE(cl_asmbal, FMT='(A,".nc")' ) TRIM( c_asmbal )
57
58      ! Check if file exists
59      INQUIRE( FILE = TRIM( cl_asmbal ), EXIST = llok )
60      IF( .NOT. llok ) THEN
61         IF(lwp) WRITE(numout,*) ' Setting up assimilation balancing increments file '// &
62            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
63
64         ! Define the output file       
65         CALL iom_open( c_asmbal, inum, ldwrt = .TRUE., kiolib = jprstlib)
66
67         ! Write the information
68         CALL iom_rstput( kt, kt, inum, 'rdastp' , zdate   )
69
70         IF ( ln_logchltotinc .OR. ln_logchlpftinc ) THEN
71#if defined key_fabm
72            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl1', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl1) )
73            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl2', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl2) )
74            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl3', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl3) )
75            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl4', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl4) )
76#elif defined key_medusa && defined key_foam_medusa
77            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chn', logchl_balinc(:,:,:,jpchn) )
78            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chd', logchl_balinc(:,:,:,jpchd) )
79            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phn', logchl_balinc(:,:,:,jpphn) )
80            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phd', logchl_balinc(:,:,:,jpphd) )
81            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_pds', logchl_balinc(:,:,:,jppds) )
82            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zmi', logchl_balinc(:,:,:,jpzmi) )
83            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zme', logchl_balinc(:,:,:,jpzme) )
84            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_din', logchl_balinc(:,:,:,jpdin) )
85            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_sil', logchl_balinc(:,:,:,jpsil) )
86            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_fer', logchl_balinc(:,:,:,jpfer) )
87            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_det', logchl_balinc(:,:,:,jpdet) )
88            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dtc', logchl_balinc(:,:,:,jpdtc) )
89            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dic', logchl_balinc(:,:,:,jpdic) )
90            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_alk', logchl_balinc(:,:,:,jpalk) )
91            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_oxy', logchl_balinc(:,:,:,jpoxy) )
92#elif defined key_hadocc
93            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_nut', logchl_balinc(:,:,:,jp_had_nut) )
94            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phy', logchl_balinc(:,:,:,jp_had_phy) )
95            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zoo', logchl_balinc(:,:,:,jp_had_zoo) )
96            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_det', logchl_balinc(:,:,:,jp_had_det) )
97            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dic', logchl_balinc(:,:,:,jp_had_dic) )
98            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_alk', logchl_balinc(:,:,:,jp_had_alk) )
99#endif
100         ENDIF
101
102         CALL iom_close( inum )
103      ELSE
104         CALL ctl_warn( TRIM( cl_asmbal ) // ' already exists ', &
105            &           ' Therefore not writing out balancing increments at this timestep', &
106            &           ' Something has probably gone wrong somewhere' )
107         IF(lwp) WRITE(numout,*) ' Failed to set up assimilation balancing increments file '// &
108            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
109      ENDIF
110                                 
111   END SUBROUTINE asm_bal_wri
112END MODULE asmbal
Note: See TracBrowser for help on using the repository browser.