Blame view

src/extras/bio/bio_save.F90 5.92 KB
33b83817   dumoda01   Depot du modele /...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
!$Id: bio_save.F90,v 1.8 2007-03-14 12:46:07 kbk Exp $
#include"cppdefs.h"
!-----------------------------------------------------------------------
!BOP
! !ROUTINE: Storing the results
!
! !INTERFACE:
   subroutine bio_save(nlev,totn)
!
! !DESCRIPTION:
! Here, the output of biogeochemical parameters either as ascii or as
! NetCDF files is managed.
!
! !USES:
   use bio_var
4e171ca6   dumoda01   Modification du m...
16
   use output,  only: out_fmt,ts
33b83817   dumoda01   Depot du modele /...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifdef NETCDF_FMT
   use ncdfout, only: ncid
   use ncdfout, only: lon_dim,lat_dim,z_dim,time_dim,dims
   use ncdfout, only: define_mode,new_nc_variable,set_attributes,store_data
#endif
   IMPLICIT NONE
#ifdef NETCDF_FMT
#include "netcdf.inc"
!   use netcdf
#endif
!
! !INPUT PARAMETERS:
   integer, intent(in)                 :: nlev
   REALTYPE, intent(in)                :: totn
!
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
! !LOCAL VARIABLES:
   logical, save             :: first=.true.
   integer, save             :: nn
   integer, save             :: totn_id
   integer                   :: iret
   integer                   :: out_unit=67
   REALTYPE                  :: zz
   integer                   :: i,j,n
!EOP
!-----------------------------------------------------------------------
!BOC
   if (init_saved_vars) then
      init_saved_vars=.false.
      first=.true.
   end if
   select case (out_fmt)
      case (ASCII)
         if(first) then
            open(out_unit,file='bio.out',status='unknown')
            nn = ubound(cc(1,:),1)
            first = .false.
         end if
         write(out_unit,*)
         write(out_unit,*) trim(ts)
         zz = _ZERO_
         do i=nn,1,-1
            zz=zz+0.5*h(i)
            write(out_unit,115) zz,(cc(j,i) , j=1,numc)
            zz=zz+0.5*h(i)
         end do
115 format(F10.4,100(1x,E10.4E2))

      case (NETCDF)
#ifdef NETCDF_FMT
         if(first) then
            first = .false.
            dims(1) = lon_dim
            dims(2) = lat_dim
            dims(3) = z_dim
            dims(4) = time_dim

            iret = define_mode(ncid,.true.)

            do n=1,numc
               iret = new_nc_variable(ncid,var_names(n),NF_REAL, &
                                      4,dims,var_ids(n))
               iret = set_attributes(ncid,var_ids(n),       &
                                     units=var_units(n),    &
                                     long_name=var_long(n))
            end do

            !CHG2 Diagnostic de la vitesse de chute du phytoplancton (wp)
            iret = new_nc_variable(ncid,'wp',NF_REAL,4,dims,wp_id)
            iret = set_attributes(ncid,wp_id,units='m/day', &
                                  long_name='phytoplancton settling velocity')

            !CHG4 Diagnostic du PAR
            iret = new_nc_variable(ncid,'par',NF_REAL,4,dims,par_id)
            iret = set_attributes(ncid,par_id,units='W/m2',long_name='PAR')

a62e5d30   dumoda01   Complement de la ...
95
            !DD Diagnostic des fonctions de croissance
4e171ca6   dumoda01   Modification du m...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
            iret = new_nc_variable(ncid,'lumlim1',NF_REAL,4,dims,lumlim1_id)
            iret = set_attributes(ncid,lumlim1_id,units='1/day', &
                                  long_name='light limited growth rate for picophyto')
            iret = new_nc_variable(ncid,'nitlim1',NF_REAL,4,dims,nitlim1_id)
            iret = set_attributes(ncid,nitlim1_id,units='',long_name='nitrate limitation for picophyto')
            iret = new_nc_variable(ncid,'ammlim1',NF_REAL,4,dims,ammlim1_id)
            iret = set_attributes(ncid,ammlim1_id,units='',long_name='ammonium limitation for picophyto')
            iret = new_nc_variable(ncid,'lumlim2',NF_REAL,4,dims,lumlim2_id)
            iret = set_attributes(ncid,lumlim2_id,units='1/day', &
                                  long_name='light limited growth rate for microphyto')
            iret = new_nc_variable(ncid,'nitlim2',NF_REAL,4,dims,nitlim2_id)
            iret = set_attributes(ncid,nitlim2_id,units='',long_name='nitrate limitation for microphyto')
            iret = new_nc_variable(ncid,'ammlim2',NF_REAL,4,dims,ammlim2_id)
            iret = set_attributes(ncid,ammlim2_id,units='',long_name='ammonium limitation for microphyto')

            !DD Diagnostic de npar (nb de particules lagrangiennes) pour bebogage
            !iret = new_nc_variable(ncid,'npar',NF_REAL,4,dims,npar_id)
            !iret = set_attributes(ncid,npar_id,units='', &
            !                      long_name='nb of particles per level')
a62e5d30   dumoda01   Complement de la ...
115

33b83817   dumoda01   Depot du modele /...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
            dims(1) = time_dim
            iret = new_nc_variable(ncid,'totn',NF_REAL,1,dims,totn_id)
            iret = set_attributes(ncid,totn_id,units='mmol/m**2',    &
                   long_name='total N')

            iret = define_mode(ncid,.false.)
         end if

         do n=1,numc
            iret = store_data(ncid,var_ids(n),XYZT_SHAPE,nlev,array=cc(n,:))
         end do

         !CHG2 Vitesse de chute du phytoplancton (wp = ws(1,:))
         iret = store_data(ncid,wp_id,XYZT_SHAPE,nlev,array=86400*ws(1,:))

         !CHG4 PAR (par = par(:))
         iret = store_data(ncid,par_id,XYZT_SHAPE,nlev,array=par(:))

a62e5d30   dumoda01   Complement de la ...
134
         !DD
4e171ca6   dumoda01   Modification du m...
135
136
137
138
139
140
141
142
143
         iret = store_data(ncid,lumlim1_id,XYZT_SHAPE,nlev,array=lumlim1(:))
         iret = store_data(ncid,nitlim1_id,XYZT_SHAPE,nlev,array=nitlim1(:))
         iret = store_data(ncid,ammlim1_id,XYZT_SHAPE,nlev,array=ammlim1(:))
         iret = store_data(ncid,lumlim2_id,XYZT_SHAPE,nlev,array=lumlim2(:))
         iret = store_data(ncid,nitlim2_id,XYZT_SHAPE,nlev,array=nitlim2(:))
         iret = store_data(ncid,ammlim2_id,XYZT_SHAPE,nlev,array=ammlim2(:))

         !DD
         !iret = store_data(ncid,npar_id,XYZT_SHAPE,nlev,array=npar(:))
a62e5d30   dumoda01   Complement de la ...
144

33b83817   dumoda01   Depot du modele /...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
         iret = store_data(ncid,totn_id,T_SHAPE,1,scalar=totn)
#endif
      case default
         FATAL 'A non valid output format has been chosen'
         stop 'bio_save'
   end select

   return
   end subroutine bio_save
!EOC

!-----------------------------------------------------------------------
! Copyright by the GOTM-team under the GNU Public License - www.gnu.org
!-----------------------------------------------------------------------