9 use fckit_configuration_module,
only: fckit_configuration
14 use missing_values_mod
16 use fckit_mpi_module,
only: fckit_mpi_comm, fckit_mpi_sum
41 real(kind_real),
allocatable :: vals(:,:)
55 character(len=MAXVARLEN),
allocatable :: variables(:)
57 real(c_double) :: missing_value
59 logical :: linit = .false.
72 self%missing_value = missing_value(0.0)
80 use oops_variables_mod
83 type(oops_variables),
intent(in) :: vars
84 integer,
intent(in) :: nlocs
87 type(fckit_configuration) :: f_vars
91 self%missing_value = missing_value(self%missing_value)
93 self%nvar = vars%nvars()
94 allocate(self%geovals(self%nvar))
95 allocate(self%variables(self%nvar))
96 do ivar = 1, self%nvar
97 self%variables(ivar) = vars%variable(ivar)
98 self%geovals(ivar)%nlocs = nlocs
99 self%geovals(ivar)%nval = 0
112 if (
allocated(self%geovals))
then
113 do ivar = 1, self%nvar
114 if (
allocated(self%geovals(ivar)%vals))
deallocate(self%geovals(ivar)%vals)
116 deallocate(self%geovals)
118 if (
allocated(self%variables))
deallocate(self%variables)
130 character(len=*),
intent(in) :: varname
131 type(
ufo_geoval),
pointer,
intent(inout) :: geoval
133 character(len=*),
parameter :: myname_=
"ufo_geovals_get_var"
135 character(max_string) :: err_msg
139 if (.not. self%linit)
then
146 write(0,*)
'ufo_geovals_get_var looking for ',trim(varname),
' in:'
148 write(0,*)
'ufo_geovals_get_var ',jv,trim(self%variables(jv))
150 write(err_msg,*) myname_,
" ", trim(varname),
' doesnt exist'
151 call abor1_ftn(err_msg)
153 geoval => self%geovals(ivar)
162 character(len=*),
intent(in) :: varname
164 integer,
intent(in) :: k
169 self%geovals(ivar)%vals(k,:)=geoval%vals(k,:)
180 if (.not. self%linit)
then
181 call abor1_ftn(
"ufo_geovals_zero: geovals not initialized")
183 do ivar = 1, self%nvar
184 self%geovals(ivar)%vals(:,:) = 0.0
196 if (.not. self%linit)
then
197 call abor1_ftn(
"ufo_geovals_abs: geovals not initialized")
199 do ivar = 1, self%nvar
200 self%geovals(ivar)%vals = abs(self%geovals(ivar)%vals)
210 real(kind_real),
intent(inout) :: vrms
214 if (.not. self%linit)
then
215 call abor1_ftn(
"ufo_geovals_rms: geovals not initialized")
220 do jo = 1, self%nlocs
221 vrms = vrms + sum(self%geovals(jv)%vals(:,jo)**2)
222 n=n+self%geovals(jv)%nval
226 if ( n > 0) vrms = sqrt(vrms/n)
239 if (.not. self%linit)
then
240 call abor1_ftn(
"ufo_geovals_random: geovals not initialized")
242 do ivar = 1, self%nvar
243 call normal_distribution(self%geovals(ivar)%vals, 0.0_kind_real, 1.0_kind_real, rseed)
253 real(kind_real),
intent(in) :: zz
254 integer :: jv, jo, jz
256 if (.not. self%linit)
then
257 call abor1_ftn(
"ufo_geovals_scalmult: geovals not allocated")
262 do jz = 1, self%geovals(jv)%nval
263 self%geovals(jv)%vals(jz,jo) = zz * self%geovals(jv)%vals(jz,jo)
275 integer(c_int),
intent(in) :: nlocs
276 real(c_float),
intent(in) :: values(nlocs)
279 if (.not. self%linit)
then
280 call abor1_ftn(
"ufo_geovals_profmult: geovals not allocated")
285 self%geovals(jv)%vals(:,jo) = values(jo) * self%geovals(jv)%vals(:,jo)
298 integer :: jv, jo, jz
300 character(max_string) :: err_msg
302 if (.not. self%linit)
then
303 call abor1_ftn(
"ufo_geovals_scalmult: geovals not allocated")
305 if (.not. rhs%linit)
then
306 call abor1_ftn(
"ufo_geovals_scalmult: geovals not allocated")
309 if (self%nlocs /= rhs%nlocs)
then
310 call abor1_ftn(
"ufo_geovals_assign: nlocs different between lhs and rhs")
316 write(err_msg,*)
'ufo_geovals_assign: var ', trim(self%variables(jv)),
' doesnt exist in rhs'
317 call abor1_ftn(trim(err_msg))
319 if (self%geovals(jv)%nval /= rhs%geovals(iv)%nval)
then
320 write(err_msg,*)
'ufo_geovals_assign: nvals for var ', trim(self%variables(jv)),
' are different in lhs and rhs'
321 call abor1_ftn(trim(err_msg))
324 do jz = 1, self%geovals(jv)%nval
325 self%geovals(jv)%vals(jz,jo) = rhs%geovals(iv)%vals(jz,jo)
336 character(len=*),
intent(in) :: varname
337 character(len=*),
intent(in) :: zdir
341 character(max_string) :: err_msg
342 integer:: iobs, ivar, ival, kval
343 logical :: do_flip = .false.
345 if (.not. self%linit)
then
346 call abor1_ftn(
"ufo_geovals_reorderzdir: geovals not allocated")
351 if (
associated(geoval))
then
352 print *,
'ufo_geovals_reorderzdir: geoval vertical coordinate variable ', trim(varname), geoval%nval, geoval%nlocs
354 write(err_msg, *)
'ufo_geovals_reorderzdir: geoval vertical coordinate variable ', trim(varname),
' doesnt exist'
358 if ((zdir ==
"bottom2top" .and. geoval%vals(1,1) < geoval%vals(geoval%nval,1)) .or. &
359 (zdir ==
"top2bottom" .and. geoval%vals(1,1) > geoval%vals(geoval%nval,1)))
then
361 print *,
'ufo_geovals_reorderzdir: do_flip ', do_flip
362 else if (zdir /=
"bottom2top" .or. zdir /=
"top2bottom")
then
363 write(err_msg, *)
'ufo_geovals_reorderzdir: z-coordinate direction ', trim(zdir),
' not defined'
365 print *,
'no need to reorder variables in vertical direction (zdir) do_flip ', do_flip
372 do ivar = 1, self%nvar
373 do ival = 1, self%geovals(ivar)%nval
374 kval = self%geovals(ivar)%nval - ival + 1
375 self%geovals(ivar)%vals(ival,:) = selfclone%geovals(ivar)%vals(kval,:)
391 integer :: jv, jo, jz
393 character(max_string) :: err_msg
395 if (.not. self%linit)
then
396 call abor1_ftn(
"ufo_geovals_add: geovals not allocated")
398 if (.not. other%linit)
then
399 call abor1_ftn(
"ufo_geovals_add: geovals not allocated")
402 if (self%nlocs /= other%nlocs)
then
403 call abor1_ftn(
"ufo_geovals_add: nlocs different between lhs and rhs")
409 if (self%geovals(jv)%nval /= other%geovals(iv)%nval)
then
410 write(err_msg,*)
'ufo_geovals_add: nvals for var ', trim(self%variables(jv)),
' are different in lhs and rhs'
411 call abor1_ftn(trim(err_msg))
414 do jz = 1, self%geovals(jv)%nval
415 self%geovals(jv)%vals(jz,jo) = self%geovals(jv)%vals(jz,jo) + other%geovals(iv)%vals(jz,jo)
430 integer :: jv, jo, jz
432 character(max_string) :: err_msg
434 if (.not. self%linit)
then
435 call abor1_ftn(
"ufo_geovals_diff: geovals not allocated")
437 if (.not. other%linit)
then
438 call abor1_ftn(
"ufo_geovals_diff: geovals not allocated")
441 if (self%nlocs /= other%nlocs)
then
442 call abor1_ftn(
"ufo_geovals_diff: nlocs different between lhs and rhs")
448 if (self%geovals(jv)%nval /= other%geovals(iv)%nval)
then
449 write(err_msg,*)
'ufo_geovals_diff: nvals for var ', trim(self%variables(jv)),
' are different in lhs and rhs'
450 call abor1_ftn(trim(err_msg))
453 do jz = 1, self%geovals(jv)%nval
454 self%geovals(jv)%vals(jz,jo) = self%geovals(jv)%vals(jz,jo) - other%geovals(iv)%vals(jz,jo)
469 integer :: jv, jo, jz
471 character(max_string) :: err_msg
473 if (.not. self%linit)
then
474 call abor1_ftn(
"ufo_geovals_schurmult: geovals not allocated")
476 if (.not. other%linit)
then
477 call abor1_ftn(
"ufo_geovals_schurmult: geovals not allocated")
480 if (self%nlocs /= other%nlocs)
then
481 call abor1_ftn(
"ufo_geovals_schurmult: nlocs different between lhs and rhs")
487 if (self%geovals(jv)%nval /= other%geovals(iv)%nval)
then
488 write(err_msg,*)
'ufo_geovals_schurmult: nvals for var ', trim(self%variables(jv)),
' are different in lhs and rhs'
489 call abor1_ftn(trim(err_msg))
492 do jz = 1, self%geovals(jv)%nval
493 self%geovals(jv)%vals(jz,jo) = self%geovals(jv)%vals(jz,jo) * other%geovals(iv)%vals(jz,jo)
511 if (.not. self%linit)
then
512 call abor1_ftn(
"ufo_geovals_copy: geovals not defined")
517 other%nlocs = self%nlocs
518 other%nvar = self%nvar
519 allocate(other%variables(other%nvar))
520 other%variables(:) = self%variables(:)
522 allocate(other%geovals(other%nvar))
523 do jv = 1, other%nvar
524 other%geovals(jv)%nval = self%geovals(jv)%nval
525 other%geovals(jv)%nlocs = self%geovals(jv)%nlocs
526 allocate(other%geovals(jv)%vals(other%geovals(jv)%nval, other%geovals(jv)%nlocs))
527 other%geovals(jv)%vals(:,:) = self%geovals(jv)%vals(:,:)
530 other%missing_value = self%missing_value
543 integer,
intent(in) :: loc_index
546 if (.not. other%linit)
then
547 call abor1_ftn(
"ufo_geovals_copy_one: geovals not defined")
553 self%nvar = other%nvar
554 allocate(self%variables(self%nvar))
555 self%variables(:) = other%variables(:)
557 allocate(self%geovals(self%nvar))
559 self%geovals(jv)%nval = other%geovals(jv)%nval
560 self%geovals(jv)%nlocs = 1
561 allocate(self%geovals(jv)%vals(self%geovals(jv)%nval, self%geovals(jv)%nlocs))
562 self%geovals(jv)%vals(:,self%nlocs) = other%geovals(jv)%vals(:,loc_index)
565 self%missing_value = other%missing_value
600 use dcmip_initial_conditions_test_1_2_3,
only : test1_advection_deformation, &
601 test1_advection_hadley, test3_gravity_wave
602 use dcmip_initial_conditions_test_4,
only : test4_baroclinic_wave
607 character(*),
intent(in) :: ic
609 real(kind_real) :: pi = acos(-1.0_kind_real)
610 real(kind_real) :: deg_to_rad,rlat, rlon
611 real(kind_real) :: p0, kz, u0, v0, w0, t0, phis0, ps0, rho0, hum0
612 real(kind_real) :: q1, q2, q3, q4
613 integer :: ivar, iloc, ival
615 if (.not. self%linit)
then
616 call abor1_ftn(
"ufo_geovals_analytic_init: geovals not defined")
621 if (trim(self%variables(self%nvar)) /= trim(
var_prs))
then
622 call abor1_ftn(
"ufo_geovals_analytic_init: pressure coordinate not defined")
625 deg_to_rad = pi/180.0_kind_real
627 do ivar = 1, self%nvar-1
629 do iloc = 1, self%geovals(ivar)%nlocs
632 rlat = deg_to_rad * locs%lat(iloc)
633 rlon = deg_to_rad*modulo(locs%lon(iloc)+180.0_kind_real,360.0_kind_real) - pi
635 do ival = 1, self%geovals(ivar)%nval
640 p0 = self%geovals(self%nvar)%vals(ival,iloc)
642 init_option:
select case (trim(ic))
644 case (
"dcmip-test-1-1")
646 call test1_advection_deformation(rlon,rlat,p0,kz,0,u0,v0,w0,&
647 t0,phis0,ps0,rho0,hum0,q1,q2,q3,q4)
649 case (
"dcmip-test-1-2")
651 call test1_advection_hadley(rlon,rlat,p0,kz,0,u0,v0,w0,&
652 t0,phis0,ps0,rho0,hum0,q1)
654 case (
"dcmip-test-3-1")
656 call test3_gravity_wave(rlon,rlat,p0,kz,0,u0,v0,w0,&
657 t0,phis0,ps0,rho0,hum0)
659 case (
"dcmip-test-4-0")
661 call test4_baroclinic_wave(0,1.0_kind_real,rlon,rlat,p0,kz,0,u0,v0,w0,&
662 t0,phis0,ps0,rho0,hum0,q1,q2)
666 call abor1_ftn(
"ufo_geovals_analytic_init: invalid analytic_init")
668 end select init_option
671 if (trim(self%variables(ivar)) == trim(
var_tv))
then
674 self%geovals(ivar)%vals(ival,iloc) = t0
703 integer :: jv, jo, jz
704 real(kind_real) :: over_nloc, vrms, norm
706 if (.not. self%linit)
then
707 call abor1_ftn(
"ufo_geovals_normalize: geovals not allocated")
709 if (.not. other%linit)
then
710 call abor1_ftn(
"ufo_geovals_normalize: geovals not allocated")
712 if (self%nvar /= other%nvar)
then
713 call abor1_ftn(
"ufo_geovals_normalize: reference geovals object must have the same variables as the original")
723 over_nloc = 1.0_kind_real / &
724 (real(other%nlocs,kind_real)*real(other%geovals(jv)%nval,kind_real))
727 do jo = 1, other%nlocs
728 do jz = 1, other%geovals(jv)%nval
729 vrms = vrms + other%geovals(jv)%vals(jz,jo)**2
733 if (vrms > 0.0_kind_real)
then
734 norm = 1.0_kind_real / sqrt(vrms*over_nloc)
741 do jz = 1, self%geovals(jv)%nval
742 self%geovals(jv)%vals(jz,jo) = norm*self%geovals(jv)%vals(jz,jo)
753 real(kind_real),
intent(inout) :: gprod
755 integer :: ivar, iobs, ival, nval
756 real(kind_real) :: prod
758 type(fckit_mpi_comm),
intent(in) :: f_comm
760 if (.not. self%linit)
then
761 call abor1_ftn(
"ufo_geovals_dotprod: geovals not allocated")
764 if (.not. other%linit)
then
765 call abor1_ftn(
"ufo_geovals_dotprod: geovals not allocated")
770 do ivar = 1, self%nvar
771 nval = self%geovals(ivar)%nval
773 do iobs = 1, self%nlocs
774 if ((self%geovals(ivar)%vals(ival,iobs) .ne. self%missing_value) .and. &
775 (other%geovals(ivar)%vals(ival,iobs) .ne. self%missing_value))
then
776 prod = prod + self%geovals(ivar)%vals(ival,iobs) * &
777 other%geovals(ivar)%vals(ival,iobs)
784 call f_comm%allreduce(prod,gprod,fckit_mpi_sum())
793 integer,
intent(in) :: nlocs
796 if (other%linit)
call abor1_ftn(
"ufo_geovals_reset_sec_arg: other already have data")
799 other%nvar = self%nvar
800 other%missing_value = self%missing_value
801 allocate(other%variables(self%nvar))
802 allocate(other%geovals(self%nvar))
803 do ivar = 1, self%nvar
804 other%variables(ivar) = self%variables(ivar)
805 other%geovals(ivar)%nlocs = nlocs
806 other%geovals(ivar)%nval = self%geovals(ivar)%nval
807 allocate(other%geovals(ivar)%vals(self%geovals(ivar)%nval, nlocs))
808 other%geovals(ivar)%vals(:,:) = 0.0
810 other%linit = .false.
821 integer :: ivar, iobs
823 if (.not. self%linit) &
824 call abor1_ftn(
"ufo_geovals_split: geovals self is not allocated or has no data")
826 if (other1%linit .or. other2%linit) &
827 call abor1_ftn(
"ufo_geovals_split: geovals other1 or other2 already have data")
834 do ivar = 1, self%nvar
835 do iobs = 1, self%nlocs/2
836 other1%geovals(ivar)%vals(:,iobs) = self%geovals(ivar)%vals(:,iobs)
838 do iobs = self%nlocs/2 + 1, self%nlocs
839 other2%geovals(ivar)%vals(:,iobs - self%nlocs/2) = self%geovals(ivar)%vals(:,iobs)
842 other1%linit = .true.
843 other2%linit = .true.
854 integer :: ivar, iobs
856 if ((.not. other1%linit) .or. (.not. other2%linit)) &
857 call abor1_ftn(
"ufo_geovals_merge: geovals other1 or other2 is not allocated or has no data")
862 do ivar = 1, self%nvar
863 do iobs = 1, other1%nlocs
864 self%geovals(ivar)%vals(:,iobs) = other1%geovals(ivar)%vals(:,iobs)
866 do iobs = other1%nlocs + 1, self%nlocs
867 self%geovals(ivar)%vals(:,iobs) = &
868 other2%geovals(ivar)%vals(:,iobs - other1%nlocs)
878 integer,
intent(inout) :: kobs
879 integer,
intent(in) :: kvar
880 real(kind_real),
intent(inout) :: pmin, pmax, prms
882 integer :: jo, jz, jv
889 do jo = 1, self%nlocs
890 do jz = 1, self%geovals(jv)%nval
891 if (self%geovals(jv)%vals(jz,jo) .ne. self%missing_value)
then
893 if (self%geovals(jv)%vals(jz,jo) < pmin) pmin = self%geovals(jv)%vals(jz,jo)
894 if (self%geovals(jv)%vals(jz,jo) > pmax) pmax = self%geovals(jv)%vals(jz,jo)
895 prms = prms + self%geovals(jv)%vals(jz,jo) * self%geovals(jv)%vals(jz,jo)
899 if (kobs > 0) prms = sqrt(prms/real(kobs,kind_real))
914 real(kind_real),
intent(inout) :: mxval
915 integer,
intent(inout) :: iobs, ivar
918 real(kind_real) :: vrms
919 integer :: jv, jo, jz
921 if (.not. self%linit)
then
922 call abor1_ftn(
"ufo_geovals_maxloc: geovals not allocated")
925 mxval = 0.0_kind_real
930 do jo = 1, self%nlocs
933 do jz = 1, self%geovals(jv)%nval
934 vrms = vrms + self%geovals(jv)%vals(jz,jo)**2
937 if ( self%geovals(jv)%nval > 0 )
then
938 vrms = sqrt(vrms/real(self%geovals(jv)%nval,kind_real))
941 if (vrms > mxval)
then
956 use oops_variables_mod
959 character(max_string),
intent(in) :: filename
960 integer,
intent(in) :: loc_multiplier
961 type(c_ptr),
intent(in) :: c_obspace
962 type(oops_variables),
intent(in) :: vars
964 integer :: nlocs, gv_all_nlocs, nlocs_var
967 integer :: obs_all_nlocs
969 integer :: jloc, jloc_start, jloc_end
972 integer :: ncid, dimid, varid, vartype, ndims
973 integer,
dimension(3) :: dimids
977 character(max_string) :: err_msg
978 character(len=30) :: obs_nlocs_str
979 character(len=30) :: geo_nlocs_str
981 integer(c_size_t),
allocatable,
dimension(:) :: dist_indx
982 integer(c_size_t),
allocatable,
dimension(:) :: obs_dist_indx
984 real,
allocatable :: field2d(:,:), field1d(:)
987 call check(
'nf90_open', nf90_open(trim(filename),nf90_nowrite,ncid))
990 ierr = nf90_inq_dimid(ncid,
"nlocs", dimid)
991 if(ierr /= nf90_noerr)
then
992 write(err_msg,*)
"Error: Dimension nlocs not found in ", trim(filename)
993 call abor1_ftn(err_msg)
995 call check(
'nf90_inq_dimid', nf90_inq_dimid(ncid,
"nlocs", dimid))
996 call check(
'nf90_inquire_dimension', nf90_inquire_dimension(ncid, dimid, len = gv_all_nlocs))
1000 obs_all_nlocs = obsspace_get_gnlocs(c_obspace)
1001 obs_nlocs = obsspace_get_nlocs(c_obspace)
1002 allocate(obs_dist_indx(obs_nlocs))
1003 call obsspace_get_index(c_obspace, obs_dist_indx)
1009 if (gv_all_nlocs .lt. (loc_multiplier * obs_all_nlocs))
then
1010 write(obs_nlocs_str, *) loc_multiplier * obs_all_nlocs
1011 write(geo_nlocs_str, *) gv_all_nlocs
1012 write(err_msg,
'(7a)') &
1013 "Error: Number of locations in the geovals file (", &
1014 trim(adjustl(geo_nlocs_str)),
") must be greater than or equal to ", &
1015 "the product of loc_multiplier and number of locations in the ", &
1016 "obs file (", trim(adjustl(obs_nlocs_str)),
")"
1017 call abor1_ftn(err_msg)
1023 if (loc_multiplier >= 0)
then
1024 nlocs = loc_multiplier * obs_nlocs
1025 allocate(dist_indx(nlocs))
1027 do iloc = 1,obs_nlocs
1028 jloc_start = ((obs_dist_indx(iloc) - 1) * loc_multiplier) + 1
1029 jloc_end = obs_dist_indx(iloc) * loc_multiplier
1030 do jloc = jloc_start, jloc_end
1031 dist_indx(iloc_new) = jloc
1032 iloc_new = iloc_new + 1
1036 nlocs = - loc_multiplier * obs_nlocs
1037 allocate(dist_indx(nlocs))
1039 do jloc = 1, - loc_multiplier
1040 do iloc = 1, obs_nlocs
1041 dist_indx(iloc_new) = obs_dist_indx(iloc) + (jloc - 1) * obs_all_nlocs
1042 iloc_new = iloc_new + 1
1050 do ivar = 1, self%nvar
1052 ierr = nf90_inq_varid(ncid, self%variables(ivar), varid)
1053 if(ierr /= nf90_noerr)
then
1054 write(err_msg,*)
"Error: Variable ", trim(self%variables(ivar)),
" not found in ", trim(filename)
1055 call abor1_ftn(err_msg)
1058 call check(
'nf90_inquire_variable', nf90_inquire_variable(ncid, varid, xtype = vartype, &
1059 ndims = ndims, dimids = dimids))
1061 if (ndims == 1)
then
1062 call check(
'nf90_inquire_dimension', nf90_inquire_dimension(ncid, dimids(1), len = nlocs_var))
1063 if (nlocs_var /= gv_all_nlocs)
then
1064 call abor1_ftn(
'ufo_geovals_read_netcdf: var dim /= gv_all_nlocs')
1068 self%geovals(ivar)%nval = nval
1069 allocate(self%geovals(ivar)%vals(nval,nlocs))
1071 allocate(field1d(nlocs_var))
1072 call check(
'nf90_get_var', nf90_get_var(ncid, varid, field1d))
1073 self%geovals(ivar)%vals(1,:) = field1d(dist_indx)
1076 elseif (ndims == 2)
then
1077 call check(
'nf90_inquire_dimension', nf90_inquire_dimension(ncid, dimids(1), len = nval))
1078 call check(
'nf90_inquire_dimension', nf90_inquire_dimension(ncid, dimids(2), len = nlocs_var))
1079 if (nlocs_var /= gv_all_nlocs)
then
1080 call abor1_ftn(
'ufo_geovals_read_netcdf: var dim /= gv_all_nlocs')
1083 self%geovals(ivar)%nval = nval
1084 allocate(self%geovals(ivar)%vals(nval,nlocs))
1085 allocate(field2d(nval, nlocs_var))
1086 call check(
'nf90_get_var', nf90_get_var(ncid, varid, field2d))
1087 self%geovals(ivar)%vals(:,:) = field2d(:,dist_indx)
1091 call abor1_ftn(
'ufo_geovals_read_netcdf: can only read 1d and 2d fields')
1095 where (self%geovals(ivar)%vals > 1.0e08) self%geovals(ivar)%vals = self%missing_value
1099 if (
allocated(dist_indx))
deallocate(dist_indx)
1100 if (
allocated(obs_dist_indx))
deallocate(obs_dist_indx)
1104 call check(
'nf90_close', nf90_close(ncid))
1113 character(max_string),
intent(in) :: filename
1116 integer :: ncid, dimid_nlocs, dimid_nval, dims(2)
1117 integer,
allocatable :: ncid_var(:)
1119 allocate(ncid_var(self%nvar))
1121 call check(
'nf90_create', nf90_create(trim(filename),nf90_hdf5,ncid))
1122 call check(
'nf90_def_dim', nf90_def_dim(ncid,
'nlocs',self%nlocs, dimid_nlocs))
1123 dims(2) = dimid_nlocs
1126 call check(
'nf90_def_dim', &
1127 nf90_def_dim(ncid,trim(self%variables(i))//
"_nval",self%geovals(i)%nval, dimid_nval))
1128 dims(1) = dimid_nval
1129 call check(
'nf90_def_var', &
1130 nf90_def_var(ncid,trim(self%variables(i)),nf90_float,dims,ncid_var(i)))
1133 call check(
'nf90_enddef', nf90_enddef(ncid))
1136 call check(
'nf90_put_var', nf90_put_var(ncid,ncid_var(i),self%geovals(i)%vals(:,:)))
1139 call check(
'nf90_close', nf90_close(ncid))
1140 deallocate(ncid_var)
1146 use netcdf,
only: nf90_noerr, nf90_strerror
1149 integer,
intent (in) :: status
1150 character (len=*),
intent (in) :: action
1151 character(max_string) :: err_msg
1153 if(status /= nf90_noerr)
then
1154 write(err_msg,*)
"During action: ", trim(action),
", received error: ", trim(nf90_strerror(status))
1155 call abor1_ftn(err_msg)
1158 end subroutine check
1165 integer,
intent(in) :: iobs
1168 character(MAXVARLEN) :: varname
1171 do ivar = 1, self%nvar
1172 varname = self%variables(ivar)
1174 if (
associated(geoval))
then
1175 print *,
'geoval test: ', trim(varname), geoval%nval, geoval%vals(:,iobs)
1177 print *,
'geoval test: ', trim(varname),
' doesnt exist'