2 |
|
|
3 |
implicit none |
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 |
contains |
11 |
|
|
12 |
subroutine CreateNewField(name, my_shape) |
subroutine CreateNewField(name, my_shape) |
13 |
|
|
14 |
USE netcdf, ONLY: nf90_clobber, nf90_double, nf90_unlimited |
USE netcdf, ONLY: nf90_clobber, nf90_double, nf90_unlimited |
15 |
USE netcdf95, ONLY: nf95_create, nf95_def_dim, nf95_def_var, nf95_enddef |
USE netcdf95, ONLY: nf95_create, nf95_def_dim, nf95_def_var, nf95_enddef |
|
USE write_field, ONLY: ncid, record, fieldname, varid, nbfield |
|
16 |
|
|
17 |
character(len = *), intent(in):: name |
character(len = *), intent(in):: name |
18 |
integer, intent(in):: my_shape(:) |
integer, intent(in):: my_shape(:) |
19 |
|
|
20 |
! Local: |
! Local: |
21 |
integer Dimid(size(my_shape) + 1), n_dim |
integer Dimid(size(my_shape) + 1), n_dim, varid |
22 |
|
|
23 |
!-------------------------------------------------------------------- |
!-------------------------------------------------------------------- |
24 |
|
|
25 |
NbField = NbField + 1 |
NbField = NbField + 1 |
26 |
FieldName(NbField) = ADJUSTL(name) |
FieldName(NbField) = ADJUSTL(name) |
|
Record(NbField) = 1 |
|
27 |
n_dim = size(my_shape) |
n_dim = size(my_shape) |
28 |
|
|
29 |
call NF95_CREATE(TRIM(FieldName(NbField)) // '.nc', NF90_CLOBBER, & |
call NF95_CREATE(TRIM(FieldName(NbField)) // '.nc', NF90_CLOBBER, & |
36 |
end if |
end if |
37 |
end if |
end if |
38 |
call NF95_DEF_DIM(Ncid(NbField), 'iter', NF90_UNLIMITED, Dimid(n_dim + 1)) |
call NF95_DEF_DIM(Ncid(NbField), 'iter', NF90_UNLIMITED, Dimid(n_dim + 1)) |
39 |
call NF95_DEF_VAR(Ncid(NbField), FieldName(NbField), NF90_DOUBLE, & |
call NF95_DEF_VAR(Ncid(NbField), FieldName(NbField), NF90_DOUBLE, Dimid, & |
40 |
Dimid, Varid(NbField)) |
Varid) |
41 |
call NF95_ENDDEF(Ncid(NbField)) |
call NF95_ENDDEF(Ncid(NbField)) |
42 |
|
|
43 |
end subroutine CreateNewField |
end subroutine CreateNewField |