From b2b148e5ef2df2c880a21c103611e60423b3c145 Mon Sep 17 00:00:00 2001 From: "Jun.Wang" Date: Wed, 31 May 2023 17:23:00 +0000 Subject: [PATCH 1/5] change missing value to the same as physics 9.99e20 --- driver/fvGFS/fv_nggps_diag.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/fvGFS/fv_nggps_diag.F90 b/driver/fvGFS/fv_nggps_diag.F90 index 3d05ecfe5..b4f6c8264 100644 --- a/driver/fvGFS/fv_nggps_diag.F90 +++ b/driver/fvGFS/fv_nggps_diag.F90 @@ -103,7 +103,7 @@ module fv_nggps_diags_mod implicit none private - real, parameter:: missing_value = -1.e10 + real, parameter:: missing_value = 9.99e20 real, parameter:: stndrd_atmos_ps = 101325. real, parameter:: stndrd_atmos_lapse = 0.0065 From b8baff3c2cd77ccc46c53754e5d7b3425eb1eac2 Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Fri, 4 Aug 2023 15:40:19 +0000 Subject: [PATCH 2/5] fix fortran coding error --- driver/fvGFS/fv_ufs_restart_io.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/fvGFS/fv_ufs_restart_io.F90 b/driver/fvGFS/fv_ufs_restart_io.F90 index b114d47f9..bb1940be2 100644 --- a/driver/fvGFS/fv_ufs_restart_io.F90 +++ b/driver/fvGFS/fv_ufs_restart_io.F90 @@ -446,7 +446,7 @@ subroutine add_zaxis_to_field(field, axis_name, num_levels) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_AttributeAdd(field, convention="NetCDF", purpose="FV3-dim", & - attrList=(/trim(axis_name),trim(axis_name)//":cartesian_axis"/), rc=rc) + attrList=(/trim(axis_name)//" ",trim(axis_name)//":cartesian_axis"/), rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allocate( buffer(num_levels) ) From afab1e8378041768be75192d712fe0534268631f Mon Sep 17 00:00:00 2001 From: "samuel.trahan" Date: Sat, 9 Sep 2023 15:57:05 +0000 Subject: [PATCH 3/5] initialize srf_wnd_var2 and tracers_var3 arrays --- driver/fvGFS/fv_ufs_restart_io.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/driver/fvGFS/fv_ufs_restart_io.F90 b/driver/fvGFS/fv_ufs_restart_io.F90 index bb1940be2..2621b691b 100644 --- a/driver/fvGFS/fv_ufs_restart_io.F90 +++ b/driver/fvGFS/fv_ufs_restart_io.F90 @@ -132,6 +132,7 @@ subroutine fv_dyn_restart_register (Atm) ! srf_wnd nvar2d_srf_wnd = 2 allocate (srf_wnd_var2(nx,ny,nvar2d_srf_wnd), srf_wnd_var2_names(nvar2d_srf_wnd)) + srf_wnd_var2 = 0.0 srf_wnd_var2_names(1) = 'u_srf' srf_wnd_var2_names(2) = 'v_srf' @@ -141,6 +142,7 @@ subroutine fv_dyn_restart_register (Atm) nvar3d_tracers = ntprog+ntdiag tracers_zsize = size(Atm%q,3) allocate (tracers_var3(nx,ny,tracers_zsize,nvar3d_tracers), tracers_var3_names(nvar3d_tracers)) + tracers_var3 = 0.0 do nt = 1, ntprog call get_tracer_names(MODEL_ATMOS, nt, tracer_name) From 9da28bf469b78554f96afde6230ed5fb5ba68712 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Mon, 11 Sep 2023 13:24:45 +0000 Subject: [PATCH 4/5] Write netcdf axis variables using the same real kind as data variables --- driver/fvGFS/fv_ufs_restart_io.F90 | 12 +++++++++--- tools/fv_io.F90 | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/driver/fvGFS/fv_ufs_restart_io.F90 b/driver/fvGFS/fv_ufs_restart_io.F90 index b114d47f9..9b53772b5 100644 --- a/driver/fvGFS/fv_ufs_restart_io.F90 +++ b/driver/fvGFS/fv_ufs_restart_io.F90 @@ -435,7 +435,7 @@ subroutine add_zaxis_to_field(field, axis_name, num_levels) character(len=*), intent(in) :: axis_name integer, intent(in) :: num_levels - real(8), allocatable, dimension(:) :: buffer + real, allocatable, dimension(:) :: buffer integer :: rc, i call ESMF_AttributeAdd(field, convention="NetCDF", purpose="FV3", & @@ -485,6 +485,12 @@ subroutine write_ak_bk(Atm, timestamp) character(len=8), dimension(2) :: dim_names_2d integer :: j +#ifdef OVERLOAD_R4 + character(len=5), parameter :: axis_type = 'float' +#else + character(len=6), parameter :: axis_type = 'double' +#endif + dim_names_2d(1) = "xaxis_1" dim_names_2d(2) = "Time" @@ -501,7 +507,7 @@ subroutine write_ak_bk(Atm, timestamp) call register_axis(Fv_restart, "xaxis_1", size(Atm%ak(:), 1)) call register_axis(Fv_restart, "Time", unlimited) - call register_field(Fv_restart, "xaxis_1", "double", (/"xaxis_1"/)) + call register_field(Fv_restart, "xaxis_1", axis_type, (/"xaxis_1"/)) call register_variable_attribute(Fv_restart,"xaxis_1", "axis", "X", str_len=1) if (allocated(buffer)) deallocate(buffer) allocate(buffer(size(Atm%ak(:), 1))) @@ -510,7 +516,7 @@ subroutine write_ak_bk(Atm, timestamp) end do call write_data(Fv_restart, "xaxis_1", buffer) deallocate(buffer) - call register_field(Fv_restart, "Time", "double", (/"Time"/)) + call register_field(Fv_restart, "Time", axis_type, (/"Time"/)) call register_variable_attribute(Fv_restart, dim_names_2d(2), "cartesian_axis", "T", str_len=1) call register_variable_attribute(Fv_restart, dim_names_2d(2), "units", "time level", str_len=len("time level")) call register_variable_attribute(Fv_restart, dim_names_2d(2), "long_name", dim_names_2d(2), str_len=len(dim_names_2d(2))) diff --git a/tools/fv_io.F90 b/tools/fv_io.F90 index 359e01a59..abbd95d05 100644 --- a/tools/fv_io.F90 +++ b/tools/fv_io.F90 @@ -126,6 +126,12 @@ module fv_io_mod integer ::grid_xtdimid, grid_ytdimid, haloid, pfullid !For writing BCs integer ::grid_xtstagdimid, grid_ytstagdimid, oneid +#ifdef OVERLOAD_R4 + character(len=5), parameter :: axis_type = 'float' +#else + character(len=6), parameter :: axis_type = 'double' +#endif + contains @@ -163,7 +169,7 @@ subroutine fv_io_register_axis(file_obj, numx, xpos, numy, ypos, numz, zsize) axisname = 'xaxis_'//suffix call register_axis(file_obj, axisname, 'X', domain_position=xpos(i)) if (.not. file_obj%is_readonly) then !if writing file - call register_field(file_obj, axisname, "double", (/axisname/)) + call register_field(file_obj, axisname, axis_type, (/axisname/)) call register_variable_attribute(file_obj,axisname, "axis", "X", str_len=1) call get_global_io_domain_indices(file_obj, axisname, is, ie, buffer) call write_data(file_obj, axisname, buffer) @@ -177,7 +183,7 @@ subroutine fv_io_register_axis(file_obj, numx, xpos, numy, ypos, numz, zsize) axisname = 'yaxis_'//suffix call register_axis(file_obj, axisname, 'Y', domain_position=ypos(i)) if (.not. file_obj%is_readonly) then !if writing file - call register_field(file_obj, axisname, "double", (/axisname/)) + call register_field(file_obj, axisname, axis_type, (/axisname/)) call register_variable_attribute(file_obj,axisname, "axis", "Y", str_len=1) call get_global_io_domain_indices(file_obj, axisname, is, ie, buffer) call write_data(file_obj, axisname, buffer) @@ -191,7 +197,7 @@ subroutine fv_io_register_axis(file_obj, numx, xpos, numy, ypos, numz, zsize) axisname = 'zaxis_'//suffix call register_axis(file_obj, axisname, zsize(i)) if (.not. file_obj%is_readonly) then !if writing file - call register_field(file_obj, axisname, "double", (/axisname/)) + call register_field(file_obj, axisname, axis_type, (/axisname/)) call register_variable_attribute(file_obj,axisname, "axis", "Z", str_len=1) if (allocated(buffer)) deallocate(buffer) allocate(buffer(zsize(i))) @@ -206,7 +212,7 @@ subroutine fv_io_register_axis(file_obj, numx, xpos, numy, ypos, numz, zsize) call register_axis(file_obj, "Time", unlimited) if (.not. file_obj%is_readonly) then !if writing file - call register_field(file_obj, "Time", "double", (/"Time"/)) + call register_field(file_obj, "Time", axis_type, (/"Time"/)) call register_variable_attribute(file_obj, "Time", "cartesian_axis", "T", str_len=1) call register_variable_attribute(file_obj, "Time", "units", "time level", & str_len=len("time level")) @@ -307,7 +313,7 @@ subroutine fv_io_register_restart(Atm) call register_axis(Atm%Fv_restart, "xaxis_1", size(Atm%ak(:), 1)) call register_axis(Atm%Fv_restart, "Time", unlimited) if (.not. Atm%Fv_restart%is_readonly) then !if writing file - call register_field(Atm%Fv_restart, "xaxis_1", "double", (/"xaxis_1"/)) + call register_field(Atm%Fv_restart, "xaxis_1", axis_type, (/"xaxis_1"/)) call register_variable_attribute(Atm%Fv_restart,"xaxis_1", "axis", "X", str_len=1) if (allocated(buffer)) deallocate(buffer) allocate(buffer(size(Atm%ak(:), 1))) @@ -316,7 +322,7 @@ subroutine fv_io_register_restart(Atm) end do call write_data(Atm%Fv_restart, "xaxis_1", buffer) deallocate(buffer) - call register_field(Atm%Fv_restart, "Time", "double", (/"Time"/)) + call register_field(Atm%Fv_restart, "Time", axis_type, (/"Time"/)) call register_variable_attribute(Atm%Fv_restart, dim_names_2d(2), "cartesian_axis", "T", str_len=1) call register_variable_attribute(Atm%Fv_restart, dim_names_2d(2), "units", "time level", str_len=len("time level")) call register_variable_attribute(Atm%Fv_restart, dim_names_2d(2), "long_name", dim_names_2d(2), str_len=len(dim_names_2d(2))) From bceee884e4a99b7c6b5c62e7324200476784c714 Mon Sep 17 00:00:00 2001 From: Lauren Chilutti <60401591+laurenchilutti@users.noreply.github.com> Date: Fri, 22 Sep 2023 09:27:15 -0400 Subject: [PATCH 5/5] tools/fv_io: add missing else statement and ensures all _is_open variables to .false. when files are closed (#284) --- tools/fv_io.F90 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/fv_io.F90 b/tools/fv_io.F90 index 359e01a59..7941d04ae 100644 --- a/tools/fv_io.F90 +++ b/tools/fv_io.F90 @@ -690,8 +690,9 @@ subroutine remap_restart(Atm) call read_restart(Atm(1)%Rsf_restart, ignore_checksum=Atm(1)%flagstruct%ignore_rst_cksum) call close_file(Atm(1)%Rsf_restart) Atm(1)%Rsf_restart_is_open = .false. - call mpp_error(NOTE,'==> Warning from remap_restart: Expected file '//trim(fname)//' does not exist') - Atm%flagstruct%srf_init = .false. + else + call mpp_error(NOTE,'==> Warning from remap_restart: Expected file '//trim(fname)//' does not exist') + Atm%flagstruct%srf_init = .false. endif if ( Atm(1)%flagstruct%fv_land ) then @@ -701,6 +702,7 @@ subroutine remap_restart(Atm) if (Atm(1)%Mg_restart_is_open) then call read_data(Atm(1)%Mg_restart, 'ghprime', Atm(1)%sgh) call close_file(Atm(1)%Mg_restart) + Atm(1)%Mg_restart_is_open = .false. else call mpp_error(NOTE,'==> Warning from remap_restart: Expected file '//trim(fname)//' does not exist') endif @@ -710,6 +712,7 @@ subroutine remap_restart(Atm) if (Atm(1)%Lnd_restart_is_open) then call read_data(Atm(1)%Lnd_restart, 'oro', Atm(1)%oro) call close_file(Atm(1)%Lnd_restart) + Atm(1)%Lnd_restart_is_open = .false. else call mpp_error(NOTE,'==> Warning from remap_restart: Expected file '//trim(fname)//' does not exist') endif @@ -1294,11 +1297,13 @@ subroutine fv_io_write_BCs(Atm, timestamp) if (Atm%neststruct%BCfile_sw_is_open) then call write_restart_bc(Atm%neststruct%BCfile_sw) call close_file(Atm%neststruct%BCfile_sw) + Atm%neststruct%BCfile_sw_is_open = .false. endif if (Atm%neststruct%BCfile_ne_is_open) then call write_restart_bc(Atm%neststruct%BCfile_ne) call close_file(Atm%neststruct%BCfile_ne) + Atm%neststruct%BCfile_ne_is_open = .false. endif deallocate(all_pelist) @@ -1328,11 +1333,13 @@ subroutine fv_io_read_BCs(Atm) if (Atm%neststruct%BCfile_sw_is_open) then call read_restart_bc(Atm%neststruct%BCfile_sw, ignore_checksum=Atm%flagstruct%ignore_rst_cksum) call close_file(Atm%neststruct%BCfile_sw) + Atm%neststruct%BCfile_sw_is_open = .false. endif if (Atm%neststruct%BCfile_ne_is_open) then call read_restart_bc(Atm%neststruct%BCfile_ne, ignore_checksum=Atm%flagstruct%ignore_rst_cksum) call close_file(Atm%neststruct%BCfile_ne) + Atm%neststruct%BCfile_ne_is_open = .false. endif