Skip to content
This repository was archived by the owner on Nov 18, 2026. It is now read-only.

enable single precision build for JCSDA-internal/MPAS-Model - #27

Merged
liujake merged 10 commits into
release-stablefrom
feature/sp
May 27, 2022
Merged

liujake merged 10 commits into
release-stablefrom
feature/sp

Conversation

@metdyn

@metdyn metdyn commented Apr 19, 2022 •

Copy link
Copy Markdown

Description

This PR accompanies JCSDA-internal/mpas-jedi#728.
It solves single precision build for MPAS-Model: issue #26

To build

source env-setup/gnu-openmpi-cheyenne.sh
set(MPAS_DOUBLE_PRECISION "OFF" CACHE STRING ....) in mpas-bundle/CMakeLists.txt
ecbuild (cmake); make

Modified files

M CMakeLists.txt
M Makefile
M cmake/PackageConfig.cmake.in

Yonggang Yu added 6 commits March 31, 2022 13:18
+       "FFLAGS_OPT = -O3 -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form -fallow-argument-mismatch -fallow-invalid-boz"
Comment thread Makefile Outdated
"CXX_SERIAL = g++" \
"FFLAGS_PROMOTION = -fdefault-real-8 -fdefault-double-8" \
"FFLAGS_OPT = -O3 -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form" \
"FFLAGS_OPT = -O3 -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form -fallow-argument-mismatch -fallow-invalid-boz" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might be good to ask @mgduda what the implications of are for adding these two flags. @metdyn, do we already use these flags in the cmake build?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For what it's worth, the current MPAS v7.3 release doesn't require the -fallow-argument-mismatch -fallow-invalid-boz flags when building with the GNU 9, 10, and 11 compilers. See, e.g., PR MPAS-Dev#736 .

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you Michael! @metdyn, could you apply that same change in this branch, then remove the change to Makefile? Eventually we need to merge MPASv7.3 into our fork(s).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mgduda: that is a good fix:
integer, parameter:: bigint = int(O'17777777777')
I will make corresponding changes to this set of code deposit. Thanks for letting us know!

@metdyn

metdyn commented Apr 25, 2022 •

Copy link
Copy Markdown
Author

@mgduda:

An explicit question:
Is there a way to replace or modify iso_c_binding to alias or manipulate the keyword double in C++?
https://rgoswami.me/posts/iso-c-type-bound-fortran/

General description:
In C++, is there a way to redefine the Arithmetic Types: integral types and floating-point types: For example: standard int (meaning integer) [size 16 bits]; float (meaning single-precision floating-point) [minimum size 6 significant digits]; double (meaning double-precision floating-point) [minimum size 10 significant digits]. For exmaple, re-define in c++ code,

  double frac = 0.0; 
  const double zz = sqrt(dot_product(gv, gv));
  std::vector<double>::iterator &   ...  ;

so that double becomes an alias to float single-precision.
I feel there could be a correspondence in C or C++, to the FORTRAN functionality.

@mgduda

mgduda commented Apr 25, 2022

Copy link
Copy Markdown

@metdyn I'm not sure that I understand your last question. Are you interested in C-Fortran interoperability of Fortran type-bound procedures? Or is the question how to be able to switch between float and double for interoperable variables?

@metdyn

metdyn commented Apr 25, 2022

Copy link
Copy Markdown
Author

@metdyn I'm not sure that I understand your last question. Are you interested in C-Fortran interoperability of Fortran type-bound procedures? Or is the question how to be able to switch between float and double for interoperable variables?

I intend to ask

  • Is there a possibility to overwrite the double datatype in C or C++ code by float, so that the full C/C++ code alone (without considering any Fortran component) can execute in single precision mode?

Yes, I am interested in C-Fortran interoperability of Fortran type-bound procedures.
No. the question is how to switch float and double in the entire C code.

@metdyn

metdyn commented Apr 25, 2022 •

Copy link
Copy Markdown
Author

@metdyn I'm not sure that I understand your last question. Are you interested in C-Fortran interoperability of Fortran type-bound procedures? Or is the question how to be able to switch between float and double for interoperable variables?

I intend to ask

  • Is there a possibility to overwrite the double datatype in C or C++ code by float, so that the full C/C++ code alone (without considering any Fortran component) can execute in single precision mode?

Yes, I am interested in C-Fortran interoperability of Fortran type-bound procedures. No. the question is how to switch float and double in the entire C code.

My error in using the word switch. It is about either turn off double entirely or re-define (alias) double by float in C.

@metdyn metdyn changed the title enable single precision build for JCSDA-interl/MPAS-Model enable single precision build for JCSDA-internal/MPAS-Model May 20, 2022
…777777')

   doesn't require the -fallow-argument-mismatch -fallow-invalid-boz flags when building with
   the GNU 9, 10, and 11 compilers.
o  Remove the flags in Makefile

@liujake liujake left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some of PR message looks outdated with recent success of mpas-jedi single precision build. Need to update.

@metdyn

metdyn commented May 25, 2022

Copy link
Copy Markdown
Author

@liujake You are right. I am updating the PR message.

@jjguerrette jjguerrette left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great work @metdyn!

@metdyn

metdyn commented May 26, 2022

Copy link
Copy Markdown
Author

Will you check if I am on the authorized user list to merge? (Merging is blocked)

@jjguerrette

Copy link
Copy Markdown

@metdyn, I just added you with write privileges.

@metdyn

metdyn commented May 26, 2022

Copy link
Copy Markdown
Author

@jjguerrette Thanks, but seems that something is still missing -- merging is blocked.

@jjguerrette

Copy link
Copy Markdown

That's strange. People with write access to mpas-jedi can merge, so I assumed it would be the same here. Did you try closing your browser and re-opening? Maybe deleting cookies?

@jjguerrette

jjguerrette commented May 26, 2022 •

Copy link
Copy Markdown

I think I figured out what is different with mpas-jedi. I just added the JCSDA-internal/mpas team as having PR merge ability.

@metdyn

metdyn commented May 27, 2022

Copy link
Copy Markdown
Author

@jjguerrette I have restarted the mac. The same message appears:
Merging is blocked
The base branch restricts merging to authorized users. Learn more about protected branches.

@liujake
liujake merged commit 1ef7305 into release-stable May 27, 2022
@liujake
liujake deleted the feature/sp branch May 27, 2022 04:31
@liujake

liujake commented May 27, 2022

Copy link
Copy Markdown

I just merged it for you.

@metdyn

metdyn commented May 27, 2022

Copy link
Copy Markdown
Author

That works, thanks!

@jjguerrette

Copy link
Copy Markdown

@metdyn, I think the problem was that I forget to click the "Save Changes" button. I just made the same change and clicked the button. Hopefully it works for you and others next time.

@metdyn

metdyn commented May 27, 2022 via email

Copy link
Copy Markdown
Author

climbfuji pushed a commit that referenced this pull request Aug 26, 2022
Description
This PR accompanies JCSDA-internal/mpas-jedi#728.
It solves single precision build for MPAS-Model: issue #26

To build
source env-setup/gnu-openmpi-cheyenne.sh
set(MPAS_DOUBLE_PRECISION "OFF" CACHE STRING ....) in mpas-bundle/CMakeLists.txt
ecbuild (cmake); make

Modified files
M CMakeLists.txt
M Makefile
M cmake/PackageConfig.cmake.in
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants