Skip to content

Commit

Permalink
Merge branch 'NOAA-GFDL:main' into mpp_gatscat_update
Browse files Browse the repository at this point in the history
  • Loading branch information
abrooks1085 authored Aug 6, 2024
2 parents 39f8a7b + a5de6a5 commit 7379975
Show file tree
Hide file tree
Showing 71 changed files with 1,423 additions and 875 deletions.
11 changes: 6 additions & 5 deletions CMAKE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,18 @@ make install
```

### User configurable options:
By default, FMS is built without `OpenMP` and in `single precision (r4)`
By default, FMS is built without `OpenMP`, in `single precision (r4)` and delivered in static library files.

The 64BIT and 32BIT precision options will build distinct libraries when enabled with the given default
real size, libfms_r4 or libfms_r8.

The following build options are available:
```
-DOPENMP "Build FMS with OpenMP support" DEFAULT: OFF
-D32BIT "Build 32-bit (r4) FMS library" DEFAULT: ON
-D64BIT "Build 64-bit (r8) FMS library" DEFAULT: OFF
-DFPIC "Build with position independent code" DEFAULT: OFF
-DOPENMP "Build FMS with OpenMP support" DEFAULT: OFF
-D32BIT "Build 32-bit (r4) FMS library" DEFAULT: ON
-D64BIT "Build 64-bit (r8) FMS library" DEFAULT: OFF
-DFPIC "Build with position independent code" DEFAULT: OFF
-DSHARED_LIBS "Build shared/dynamic libraries" DEFAULT: OFF
-DCONSTANTS "Build with <X> constants parameter definitions" DEFAULT:GFDL OPTIONS:GFS|GEOS|GFDL
-DINTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" DEFAULT: ON
Expand Down
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Build options
option(OPENMP "Build FMS with OpenMP support" OFF)
option(32BIT "Build 32-bit (r4) FMS library" ON)
option(64BIT "Build 64-bit (r8) FMS library" OFF)
option(FPIC "Build with position independent code" OFF)
option(OPENMP "Build FMS with OpenMP support" OFF)
option(32BIT "Build 32-bit (r4) FMS library" ON)
option(64BIT "Build 64-bit (r8) FMS library" OFF)
option(FPIC "Build with position independent code" OFF)
option(SHARED_LIBS "Build shared/dynamic libraries" OFF)

# Options for compiler definitions
option(INTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" ON)
Expand Down Expand Up @@ -360,8 +361,15 @@ foreach(kind ${kinds})
endif()

# FMS (C + Fortran)
add_library(${libTgt} STATIC $<TARGET_OBJECTS:${libTgt}_c>
$<TARGET_OBJECTS:${libTgt}_f>)
if (SHARED_LIBS)
message(STATUS "Shared library target: ${libTgt}")
add_library(${libTgt} SHARED $<TARGET_OBJECTS:${libTgt}_c>
$<TARGET_OBJECTS:${libTgt}_f>)
else ()
message(STATUS "Static library target: ${libTgt}")
add_library(${libTgt} STATIC $<TARGET_OBJECTS:${libTgt}_c>
$<TARGET_OBJECTS:${libTgt}_f>)
endif ()

target_include_directories(${libTgt} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -397,7 +405,8 @@ foreach(kind ${kinds})
target_compile_definitions(${libTgt} PRIVATE "${fms_defs}")
target_compile_definitions(${libTgt} PRIVATE "${${kind}_defs}")

target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_Fortran
target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_C
NetCDF::NetCDF_Fortran
MPI::MPI_Fortran)

if(OpenMP_Fortran_FOUND)
Expand Down
6 changes: 3 additions & 3 deletions amip_interp/amip_interp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ module amip_interp_mod
NOTE, mpp_error, fms_error_handler

use constants_mod, only: TFREEZE, pi
use platform_mod, only: r4_kind, r8_kind, i2_kind
use platform_mod, only: r4_kind, r8_kind, i2_kind, FMS_FILE_LEN
use mpp_mod, only: input_nml_file
use fms2_io_mod, only: FmsNetcdfFile_t, fms2_io_file_exists=>file_exists, open_file, close_file, &
get_dimension_size, fms2_io_read_data=>read_data
use netcdf, only: NF90_MAX_NAME

implicit none
private
Expand Down Expand Up @@ -302,9 +303,8 @@ module amip_interp_mod

! ---- global unit & date ----

integer, parameter :: maxc = 128
integer :: iunit
character(len=maxc) :: file_name_sst, file_name_ice
character(len=FMS_FILE_LEN) :: file_name_sst, file_name_ice
type(FmsNetcdfFile_t), target :: fileobj_sst, fileobj_ice

type (date_type) :: Curr_date = date_type( -99, -99, -99 )
Expand Down
5 changes: 3 additions & 2 deletions amip_interp/include/amip_interp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ subroutine GET_AMIP_SST_ (Time, Interp, sst, err_msg, lon_model, lat_model)
integer, dimension(:), allocatable :: ryr, rmo, rdy
character(len=30) :: time_unit
real(FMS_AMIP_INTERP_KIND_), dimension(:), allocatable :: timeval
character(len=maxc) :: ncfilename
character(len=FMS_FILE_LEN) :: ncfilename
type(FmsNetcdfFile_t) :: fileobj
logical :: the_file_exists
! end add by JHC
Expand Down Expand Up @@ -652,7 +652,8 @@ endif
integer(I2_KIND) :: idat(mobs,nobs)
integer :: nrecords, yr, mo, dy, ierr, k
integer, dimension(:), allocatable :: ryr, rmo, rdy
character(len=maxc) :: ncfilename, ncfieldname
character(len=FMS_FILE_LEN) :: ncfilename
character(len=NF90_MAX_NAME) :: ncfieldname
type(FmsNetcdfFile_t), pointer :: fileobj
integer, parameter :: lkind = FMS_AMIP_INTERP_KIND_

Expand Down
2 changes: 1 addition & 1 deletion column_diagnostics/column_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module column_diagnostics_mod
get_date, time_type
use constants_mod, only: constants_init, PI, RADIAN
use mpp_mod, only: input_nml_file
use platform_mod, only: r4_kind, r8_kind
use platform_mod, only: r4_kind, r8_kind, FMS_FILE_LEN
!-------------------------------------------------------------------

implicit none
Expand Down
2 changes: 1 addition & 1 deletion column_diagnostics/include/column_diagnostics.inc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ integer, dimension(:), intent(out) :: diag_units !< unit number for
real(FMS_CD_KIND_) :: ref_lat
real(FMS_CD_KIND_) :: current_distance
character(len=8) :: char !< character string for diaganostic column index
character(len=32) :: filename !< filename for output file for diagnostic column
character(len=FMS_FILE_LEN) :: filename !< filename for output file for diagnostic column
logical :: allow_ij_input
logical :: open_file
integer :: io
Expand Down
8 changes: 4 additions & 4 deletions coupler/atmos_ocean_fluxes.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module atmos_ocean_fluxes_mod
use coupler_types_mod, only: ind_runoff
use coupler_types_mod, only: ind_flux, ind_deltap, ind_kw, ind_flux0

use field_manager_mod, only: fm_path_name_len, fm_string_len, fm_exists, fm_get_index
use field_manager_mod, only: fm_string_len, fm_exists, fm_get_index
use field_manager_mod, only: fm_new_list, fm_get_current_list, fm_change_list
use field_manager_mod, only: fm_field_name_len, fm_type_name_len, fm_dump_list
use field_manager_mod, only: fm_loop_over_list
Expand All @@ -63,7 +63,7 @@ module atmos_ocean_fluxes_mod
use fm_util_mod, only: fm_util_get_real_array, fm_util_get_real, fm_util_get_integer
use fm_util_mod, only: fm_util_get_logical, fm_util_get_logical_array
use fms_io_utils_mod, only: get_data_type_string
use platform_mod, only: r4_kind, r8_kind
use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN

implicit none
private
Expand Down Expand Up @@ -135,8 +135,8 @@ function aof_set_coupler_flux(name, flux_type, implementation, atm_tr_index, par
integer :: length
integer :: num_parameters
integer :: outunit
character(len=fm_path_name_len) :: coupler_list
character(len=fm_path_name_len) :: current_list
character(len=FMS_PATH_LEN) :: coupler_list
character(len=FMS_PATH_LEN) :: current_list
character(len=fm_string_len) :: flux_type_test
character(len=fm_string_len) :: implementation_test
character(len=256) :: error_header
Expand Down
38 changes: 19 additions & 19 deletions coupler/coupler_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module coupler_types_mod
use mpp_domains_mod, only: domain2D, mpp_redistribute
use mpp_mod, only: mpp_error, FATAL, mpp_chksum
use fms_string_utils_mod, only: string
use platform_mod, only: r4_kind, r8_kind, i8_kind
use platform_mod, only: r4_kind, r8_kind, i8_kind, FMS_FILE_LEN, FMS_PATH_LEN

implicit none
private
Expand Down Expand Up @@ -103,8 +103,8 @@ module coupler_types_mod
character(len=128) :: implementation = ' ' !< implementation
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -146,8 +146,8 @@ module coupler_types_mod
character(len=128) :: implementation = ' ' !< implementation
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -207,8 +207,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -253,8 +253,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=124) :: ice_restart_file = ' ' !< ice_restart_file
character(len=124) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -309,8 +309,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
logical :: use_atm_pressure !< use_atm_pressure
logical :: use_10m_wind_speed !< use_10m_wind_speed
logical :: pass_through_ice !< pass_through_ice
Expand Down Expand Up @@ -350,8 +350,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
logical :: use_atm_pressure !< use_atm_pressure
logical :: use_10m_wind_speed !< use_10m_wind_speed
logical :: pass_through_ice !< pass_through_ice
Expand Down Expand Up @@ -3076,15 +3076,15 @@ subroutine CT_register_restarts_2d(var, bc_rest_files, num_rest_files, mpp_domai
logical, optional,intent(in) :: ocean_restart !< If true, use the ocean restart file name.
character(len=*),optional,intent(in) :: directory !< Directory where to open the file

character(len=80), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=80) :: file_nm
character(len=FMS_FILE_LEN), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=FMS_FILE_LEN) :: file_nm
logical :: ocn_rest
integer :: f, n, m

character(len=20), allocatable, dimension(:) :: dim_names !< Array of dimension names
character(len=20) :: io_type !< flag indicating io type: "read" "overwrite"
logical, dimension(max(1,var%num_bcs)) :: file_is_open !< flag indicating if file is open
character(len=20) :: dir !< Directory where to open the file
character(len=FMS_PATH_LEN) :: dir !< Directory where to open the file

if(var%set .and. var%num_bcs .gt. 0) then
if(associated(var%bc) .eqv. associated(var%bc_r4)) then
Expand Down Expand Up @@ -3358,15 +3358,15 @@ subroutine CT_register_restarts_3d(var, bc_rest_files, num_rest_files, mpp_domai
logical, optional,intent(in) :: ocean_restart !< If true, use the ocean restart file name.
character(len=*),optional,intent(in) :: directory !< Directory where to open the file

character(len=80), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=80) :: file_nm
character(len=FMS_FILE_LEN), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=FMS_FILE_LEN) :: file_nm
logical :: ocn_rest
integer :: f, n, m

character(len=20), allocatable, dimension(:) :: dim_names !< Array of dimension names
character(len=20) :: io_type !< flag indicating io type: "read" "overwrite"
logical, dimension(max(1,var%num_bcs)) :: file_is_open !< Flag indicating if file is open
character(len=20) :: dir !< Directory where to open the file
character(len=FMS_PATH_LEN) :: dir !< Directory where to open the file
integer :: nz !< Length of the z direction of each file

if(var%set .and. var%num_bcs .gt. 0) then
Expand Down
Loading

0 comments on commit 7379975

Please sign in to comment.