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 @ 6983

Last change on this file since 6983 was 6983, checked in by dford, 8 years ago

An initial version of code to apply chlorophyll increments to FABM-ERSEM.

File size: 8.2 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_ersem_chl1', logchl_balinc_ersem_chl1 )
73            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_chl2', logchl_balinc_ersem_chl2 )
74            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_chl3', logchl_balinc_ersem_chl3 )
75            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_chl4', logchl_balinc_ersem_chl4 )
76            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p1c',  logchl_balinc_ersem_p1c  )
77            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p1n',  logchl_balinc_ersem_p1n  )
78            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p1p',  logchl_balinc_ersem_p1p  )
79            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p1s',  logchl_balinc_ersem_p1s  )
80            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p2c',  logchl_balinc_ersem_p2c  )
81            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p2n',  logchl_balinc_ersem_p2n  )
82            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p2p',  logchl_balinc_ersem_p2p  )
83            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p3c',  logchl_balinc_ersem_p3c  )
84            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p3n',  logchl_balinc_ersem_p3n  )
85            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p3p',  logchl_balinc_ersem_p3p  )
86            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p4c',  logchl_balinc_ersem_p4c  )
87            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p4n',  logchl_balinc_ersem_p4n  )
88            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_p4p',  logchl_balinc_ersem_p4p  )
89            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z4c',  logchl_balinc_ersem_z4c  )
90            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z5c',  logchl_balinc_ersem_z5c  )
91            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z5n',  logchl_balinc_ersem_z5n  )
92            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z5p',  logchl_balinc_ersem_z5p  )
93            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z6c',  logchl_balinc_ersem_z6c  )
94            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z6n',  logchl_balinc_ersem_z6n  )
95            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_z6p',  logchl_balinc_ersem_z6p  )
96            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_n1p',  logchl_balinc_ersem_n1p  )
97            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_n3n',  logchl_balinc_ersem_n3n  )
98            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_n4n',  logchl_balinc_ersem_n4n  )
99            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_ersem_n5s',  logchl_balinc_ersem_n5s  )
100#elif defined key_medusa && defined key_foam_medusa
101            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_chn', logchl_balinc_medusa_chn )
102            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_chd', logchl_balinc_medusa_chd )
103            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_phn', logchl_balinc_medusa_phn )
104            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_phd', logchl_balinc_medusa_phd )
105            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_pds', logchl_balinc_medusa_pds )
106            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_zmi', logchl_balinc_medusa_zmi )
107            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_zme', logchl_balinc_medusa_zme )
108            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_din', logchl_balinc_medusa_din )
109            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_sil', logchl_balinc_medusa_sil )
110            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_fer', logchl_balinc_medusa_fer )
111            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_det', logchl_balinc_medusa_det )
112            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_dtc', logchl_balinc_medusa_dtc )
113            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_dic', logchl_balinc_medusa_dic )
114            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_alk', logchl_balinc_medusa_alk )
115            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_medusa_oxy', logchl_balinc_medusa_oxy )
116#elif defined key_hadocc
117            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_hadocc_nut', logchl_balinc_hadocc_nut )
118            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_hadocc_phy', logchl_balinc_hadocc_phy )
119            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_hadocc_zoo', logchl_balinc_hadocc_zoo )
120            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_hadocc_det', logchl_balinc_hadocc_det )
121            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_hadocc_dic', logchl_balinc_hadocc_dic )
122            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_hadocc_alk', logchl_balinc_hadocc_alk )
123#endif
124         ENDIF
125
126         CALL iom_close( inum )
127      ELSE
128         CALL ctl_warn( TRIM( cl_asmbal ) // ' already exists ', &
129            &           ' Therefore not writing out balancing increments at this timestep', &
130            &           ' Something has probably gone wrong somewhere' )
131         IF(lwp) WRITE(numout,*) ' Failed to set up assimilation balancing increments file '// &
132            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
133      ENDIF
134                                 
135   END SUBROUTINE asm_bal_wri
136END MODULE asmbal
Note: See TracBrowser for help on using the repository browser.