/[lmdze]/trunk/misc/createnewfield.f90
ViewVC logotype

Contents of /trunk/misc/createnewfield.f90

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (show annotations)
Thu Jun 13 14:40:06 2019 UTC (4 years, 11 months ago) by guez
File size: 1364 byte(s)
Change all `.f` suffixes to `.f90`. (The opposite was done in revision
82.)  Because of change of philosopy in GNUmakefile: we already had a
rewritten rule for `.f`, so it does not make the makefile longer to
replace it by a rule for `.f90`. And it spares us options of
makedepf90 and of the compiler. Also we prepare the way for a simpler
`CMakeLists.txt`.

1 module createnewfield_m
2
3 implicit none
4
5 integer, parameter:: MaxWriteField = 100
6 character(len=255), save:: FieldName(MaxWriteField)
7 integer:: NbField = 0
8 integer, save:: Ncid(MaxWriteField)
9
10 contains
11
12 subroutine CreateNewField(name, my_shape)
13
14 USE netcdf, ONLY: nf90_clobber, nf90_double, nf90_unlimited
15 USE netcdf95, ONLY: nf95_create, nf95_def_dim, nf95_def_var, nf95_enddef
16
17 character(len = *), intent(in):: name
18 integer, intent(in):: my_shape(:)
19
20 ! Local:
21 integer Dimid(size(my_shape) + 1), n_dim, varid
22
23 !--------------------------------------------------------------------
24
25 NbField = NbField + 1
26 FieldName(NbField) = ADJUSTL(name)
27 n_dim = size(my_shape)
28
29 call NF95_CREATE(TRIM(FieldName(NbField)) // '.nc', NF90_CLOBBER, &
30 Ncid(NbField))
31 call NF95_DEF_DIM(Ncid(NbField), 'X', my_shape(1), Dimid(1))
32 if (n_dim >= 2) then
33 call NF95_DEF_DIM(Ncid(NbField), 'Y', my_shape(2), Dimid(2))
34 if (n_dim >= 3) then
35 call NF95_DEF_DIM(Ncid(NbField), 'Z', my_shape(3), Dimid(3))
36 end if
37 end if
38 call NF95_DEF_DIM(Ncid(NbField), 'iter', NF90_UNLIMITED, Dimid(n_dim + 1))
39 call NF95_DEF_VAR(Ncid(NbField), FieldName(NbField), NF90_DOUBLE, Dimid, &
40 Varid)
41 call NF95_ENDDEF(Ncid(NbField))
42
43 end subroutine CreateNewField
44
45 end module createnewfield_m

  ViewVC Help
Powered by ViewVC 1.1.21