Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jimmielin/sphere_foo
Toy Foo et al. parameterization
https://github.com/jimmielin/sphere_foo
Last synced: about 2 months ago
JSON representation
Toy Foo et al. parameterization
- Host: GitHub
- URL: https://github.com/jimmielin/sphere_foo
- Owner: jimmielin
- License: lgpl-3.0
- Created: 2024-06-02T02:05:48.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-02T02:47:24.000Z (7 months ago)
- Last Synced: 2024-06-11T16:49:39.240Z (7 months ago)
- Language: Fortran
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.LGPL
Awesome Lists containing this project
README
# Foo et al. Parameterization
This is a toy software package that calculates the complex Foo et al. parametrization to calculate the volume of a sphere based on its radius.
## Building
To build the standalone Foo et al. library with `gfortran` as an example:
```bash
gfortran -c sphere_foo_common.F90 sphere_foo.F90
```### Interactive Example
You can build this library and use it interactively (i.e., on a command line) using
```bash
# To build:
gfortran -c sphere_foo_common.F90 sphere_foo.F90
gfortran -c examples/interactive_sphere_foo.F90 -o examples/interactive_sphere_foo.o
gfortran sphere_foo_common.o sphere_foo.o examples/interactive_sphere_foo.o -o examples/interactive_sphere_foo.exe# To run:
./examples/interactive_sphere_foo.exe
```Running the program looks like:
```
Input radius for Foo et al. (Ctrl-C or input negative number to quit):
1
Radius = 1.0000000000000000 , calculated volume = 4.1887901282943290
Input radius for Foo et al. (Ctrl-C or input negative number to quit):
2
Radius = 2.0000000000000000 , calculated volume = 33.510321026354632
Input radius for Foo et al. (Ctrl-C or input negative number to quit):
-1
Exiting.
```### Implementation Example
Example code for running the parameterization is available in the `examples/` folder. To build it and link to the library, use:
```bash
gfortran -c examples/example_program.F90 -o examples/example_program.o
gfortran sphere_foo_common.o sphere_foo.o examples/example_program.o -o examples/example_program.exe
```Run `./examples/example_program.exe` to see the toy example:
```bash
gfortran -c sphere_foo_common.F90 sphere_foo.F90
gfortran -c examples/example_program.F90 -o examples/example_program.o
gfortran sphere_foo_common.o sphere_foo.o examples/example_program.o -o examples/example_program.exe
./examples/example_program.exe# Expected output:
# Radius = 1.0000000000000000 , calculated volume = 4.1887901282943290
# Radius = 2.0000000000000000 , calculated volume = 33.510321026354632
```## Implementing in external model
The `sphere_foo` library uses a initialize, run, finalize pattern and accepts the `pi` physical constant from the external model to avoid duplication and maintain consistency. All subroutine calls include a return code (compatible with ESMF) where `0` is success and `1` is error.
### Subroutine calls
* Init: Initialize the physical constants in `sphere_foo_common.F90` by calling `sphere_foo_init(pi, RC)`.
* Run: Run the parameterization by calling `sphere_foo_run(radius, volume, RC)`.
* Finalize: Cleanup the internal state by calling `sphere_foo_final(RC)`.### Precision
The real number precision is flexible and is a `fp` parameter defined in `sphere_foo_common.F90`. It defaults to `real*8` as defined in `sphere_foo_common.F90`. If a different precision is desired, `sphere_foo_common.F90` can be modified to import `fp` from the external model.## Code documentation
Code is documented using ProTeX, a perl script to generate documentation from code headers and readable comments with LaTeX support. Refer to [Automatic Documentation using ProTeX](http://wiki.seas.harvard.edu/geos-chem/index.php/Automatic_documentation_with_protex) from the GEOS-Chem Wiki for more information about this feature.Changelogs are kept in `CHANGELOG.md` based on [Keep a changelog](https://keepachangelog.com/en/1.1.0/) convention.