Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize two arrays and fix fortran coding error plus PRs #285 and #276 #280

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion driver/fvGFS/fv_ufs_restart_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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))
bensonr marked this conversation as resolved.
Show resolved Hide resolved
srf_wnd_var2 = 0.0
srf_wnd_var2_names(1) = 'u_srf'
srf_wnd_var2_names(2) = 'v_srf'

Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice in multi-threaded simulations is to loop over elements to ensure each cell is allocated on the correct thread, although modern compilers might get around this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally you would be right, but not here. The correct thread is the master thread.

The rest of fv_ufs_restart_io.F90 does not use OpenMP directives. Hence, tracers_var3 is only ever used by the master thread. Using OpenMP to initialize tracers_var3 would distribute it across multiple CPUs. If some threads are in different NUMA nodes than the master thread, then this will slow down the program.

Adding OpenMP directives throughout fv_ufs_restart_io.F90 is outside the scope of this PR. Also, there may be good reasons why the restart code is single-threaded. I can't think of any, but somebody probably implemented it this way for a reason.


do nt = 1, ntprog
call get_tracer_names(MODEL_ATMOS, nt, tracer_name)
Expand Down Expand Up @@ -446,7 +448,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) )
Expand Down
11 changes: 9 additions & 2 deletions tools/fv_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,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
Expand All @@ -707,6 +708,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
Expand All @@ -716,6 +718,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
Expand Down Expand Up @@ -1300,11 +1303,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)
Expand Down Expand Up @@ -1334,11 +1339,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


Expand Down