ESCOMP / ESCOMP/CMEPS

how to build stand alone library of cmeps?

Open
#465 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Fortran
Stars
35
Forks
106
Avg merge
6d 5h
Merged PRs (30d)
4

Description

Short version:

How do I build CMEPS as a library that can be used as the mediator for an ESMF/NUOPC coupled model? I've tried a few obvious approaches but none have worked and I have not been able to find instructions in the repo.

Long version:

I'm attempting to use CMEPS as a replacement mediator for our own ESM comprising a set of NUOPC-compliant coupled models.

I'd like to build cmeps as a library, similar to what is specified in the [Makefile](https://github.com/ESCOMP/CMEPS/blob/main/mediator/Makefile) as:
https://github.com/ESCOMP/CMEPS/blob/6384ff4e4a6bc82a678f9419a43ffbd5d53ac209/mediator/Makefile#L18
so that we can create an [ESMF makefile fragment](https://earthsystemmodeling.org/docs/release/ESMF_8_6_0/NUOPC_howtodoc/node4.html#SECTION00045000000000000000) for CMEPS and then use it to replace our own med.F90 mediator.

I have installed the ParallelIO package (which was not mentioned in the documentation, but seemed to be needed by the [CMakeLists.txt](https://github.com/ESCOMP/CMEPS/blob/main/CMakeLists.txt) and [Makefile](https://github.com/ESCOMP/CMEPS/blob/main/mediator/Makefile) as required dependencies). After setting `export PIO=/opt/PIO`, where I installed it, the Makefile runs but is looking for additional routines that are in files in application-specific directories. While some are in the `../ufs` directory in this repository, others are completely outside of this repository (as far as I can tell), for example I found some in the [UFS repo](https://github.com/ufs-community/ufs-weather-model/tree/develop/CDEPS-interface/ufs/cdeps_share) and [CDEPS repo](https://github.com/ESCOMP/CDEPS/tree/main/share).

As an alternative, I've tried building with cmake. The Readme does not have any instructions for building. So assuming it is something like:
```
cmake .
make
```

I get this error:
```
[ 16%] Building Fortran object mediator/CMakeFiles/cmeps.dir/med_methods_mod.F90.o
/tmp/CMEPS/mediator/med_methods_mod.F90(2642): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [SHR_INFNAN_MOD]
use shr_infnan_mod, only: shr_infnan_isnan
--------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2658): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [SHR_INFNAN_MOD]
use shr_infnan_mod, only: shr_infnan_isnan
--------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2651): error #6404: This name does not have a type, and must have an explicit type. [SHR_INFNAN_ISNAN]
if (shr_infnan_isnan(dataptr(n))) then
-----------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2651): error #6341: A logical data type is required in this context. [SHR_INFNAN_ISNAN]
if (shr_infnan_isnan(dataptr(n))) then
-----------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2642): error #6580: Name in only-list does not exist or is not accessible. [SHR_INFNAN_ISNAN]
use shr_infnan_mod, only: shr_infnan_isnan
------------------------------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2668): error #6406: Conflicting attributes or multiple declaration of name. [SHR_INFNAN_ISNAN]
if (shr_infnan_isnan(dataptr(k,n))) then
--------------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2668): error #6341: A logical data type is required in this context. [SHR_INFNAN_ISNAN]
if (shr_infnan_isnan(dataptr(k,n))) then
--------------^
/tmp/CMEPS/mediator/med_methods_mod.F90(2658): error #6580: Name in only-list does not exist or is not accessible. [SHR_INFNAN_ISNAN]
use shr_infnan_mod, only: shr_infnan_isnan
------------------------------^
compilation aborted for /tmp/CMEPS/mediator/med_methods_mod.F90 (code 1)
make[2]: *** [mediator/CMakeFiles/cmeps.dir/build.make:89: mediator/CMakeFiles/cmeps.dir/med_methods_mod.F90.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:142: mediator/CMakeFiles/cmeps.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
```
which is clearly looking for the missing files that are found in either the [CDEPS](https://github.com/ESCOMP/CDEPS/tree/main/share) or [UFS](https://github.com/ufs-community/ufs-weather-model/tree/develop/CDEPS-interface/ufs/cdeps_share) repositories.

I tried just copying them into the local `shared` directory and adding them to the CMakeLists.txt files, but that did not seem to be sufficient. In that case I get this error:

```
[ 13%] Built target cmeps_share
Scanning dependencies of target shared
[ 15%] Building Fortran object shared/CMakeFiles/shared.dir/shr_kind_mod.F90.o
[ 17%] Building Fortran object shared/CMakeFiles/shared.dir/shr_infnan_mod.F90.o
/tmp/CMEPS/shared/shr_infnan_mod.F90(76): error #7950: Procedure name in MODULE PROCEDURE statement must be the name of accessible module procedure. [SHR_INFNAN_ISNAN_DOUBLE]
module procedure shr_infnan_isnan_double
--------------------^
/tmp/CMEPS/shared/shr_infnan_mod.F90(78): error #7950: Procedure name in MODULE PROCEDURE statement must be the name of accessible module procedure. [SHR_INFNAN_ISNAN_REAL]
module procedure shr_infnan_isnan_real
--------------------^
/tmp/CMEPS/shared/shr_infnan_mod.F90(76): error #7407: Unresolved MODULE PROCEDURE specification name. [SHR_INFNAN_ISNAN_DOUBLE]
module procedure shr_infnan_isnan_double
--------------------^
/tmp/CMEPS/shared/shr_infnan_mod.F90(78): error #7407: Unresolved MODULE PROCEDURE specification name. [SHR_INFNAN_ISNAN_REAL]
module procedure shr_infnan_isnan_real
--------------------^

```

Could you provide some guidance as to how to build this package? (it would be great if these notes could be added to the README.md or an INSTALL file)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.