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
Changes from 6 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