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

Conversation

SamuelTrahanNOAA
Copy link

@SamuelTrahanNOAA SamuelTrahanNOAA commented Sep 8, 2023

Description

#279: fortran coding error: string length mismatch

Wherein a string length mismatch causes an abort. The code does not follow the fortran standard on this line:

    attrList=(/trim(axis_name),trim(axis_name)//":cartesian_axis"/)

because the two strings in the array have different lengths. See #279 for details.

#281: uninitialized arrays

The srf_wnd_var2 and tracers_var3 arrays are not initialized after allocation in fv_ufs_restart_io.F90. This can cause the ufs-weather-model write component's quilting restart to fail. When ESMF copies data from compute ranks to write ranks, it'll encounter NaN values if the uninitialized array happen to contain any.

How Has This Been Tested?

ufs-weather-model regression tests.

Specifically, the gnu version of the conus13km_qr_debug regression test.

The regression test can be found in this branch. To see the failure, disable this bug fix.

ufs-community/ufs-weather-model#1893

Checklist:

Please check all whether they apply or not

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@SamuelTrahanNOAA SamuelTrahanNOAA changed the title fix fortran coding error: string length mismatch in array initialize two arrays and fix fortran coding error Sep 9, 2023
driver/fvGFS/fv_ufs_restart_io.F90 Show resolved Hide resolved
@@ -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.

@zach1221
Copy link

Hello, @lharris4 @bensonr are you able to continue reviewing this PR?

@lharris4
Copy link
Contributor

lharris4 commented Sep 21, 2023 via email

@lharris4
Copy link
Contributor

BTW @bensonr is on leave today ; he should be back on Monday.

@SamuelTrahanNOAA
Copy link
Author

SamuelTrahanNOAA commented Sep 25, 2023

I've merged #283 into this PR since that one is expected to go in first. This is just to speed up the UFS test process.

In the unlikely event that #283 is rejected, I'll back out those changes.

EDIT: The testing of #283, at the ufs-weather-model level, as ufs-community/ufs-weather-model#1903, is almost done.

@lharris4
Copy link
Contributor

lharris4 commented Sep 25, 2023 via email

@bensonr
Copy link
Contributor

bensonr commented Sep 26, 2023

I've merged #283 into this PR since that one is expected to go in first. This is just to speed up the UFS test process.

In the unlikely event that #283 is rejected, I'll back out those changes.

EDIT: The testing of #283, at the ufs-weather-model level, as ufs-community/ufs-weather-model#1903, is almost done.

As you've included this here, should we have @DusanJovic-NOAA close the #283?

@SamuelTrahanNOAA
Copy link
Author

As you've included this here, should we have @DusanJovic-NOAA close the #283?

No. That PR should be merged now.

@laurenchilutti
Copy link
Contributor

@SamuelTrahanNOAA I have just merged PR 283 into the dev/emc branch, but this PR is still showing the changes from PR 283 in the list of changes. Could you please merge in dev/emc branch to this branch? I believe that GitHub is confusing your merge of Dusan's changes in commit 81f254d with the actual PR 283 dev/emc merge commit.

@SamuelTrahanNOAA
Copy link
Author

Could you please merge in dev/emc branch to this branch?

I have merged dev/emc to this branch. Please wait to merge my PR until the UFS code managers finish testing it at the ufs-weather-model level.

@SamuelTrahanNOAA
Copy link
Author

This PR now includes #285 and #276 by request of @laurenchilutti. I've tested #285 on six platforms. I'll begin to test #276 shortly.

@SamuelTrahanNOAA SamuelTrahanNOAA changed the title initialize two arrays and fix fortran coding error initialize two arrays and fix fortran coding error plus PRs #285 and #276 Sep 29, 2023
@SamuelTrahanNOAA
Copy link
Author

Could @junwang-noaa and @laurenchilutti please confirm that your PRs were merged into this one correctly?

@jkbk2004
Copy link

@laurenchilutti As @SamuelTrahanNOAA 's mini-test went ok through ufs-community/ufs-weather-model#1893, I don't see any major issue to merge this pr. Can you go ahead to merge in this pr by the end of today?

@bensonr bensonr merged commit caba092 into NOAA-GFDL:dev/emc Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants