-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The purpose of this issues is:
This project is written in Fortran, rewrite this in Python:
Information that could help when rewritting this in Python
Goals of this project
Here is the table summarizing the goals, objectives, and technical requirements of the "NASA Ames Legacy Mars Global Climate Model" project, along with their implementation details:
| Objective | Implementation |
|---|---|
| Provide a Mars Global Climate Model (GCM) | The model is presented in the repository and is extensively documented in Haberle et al. 2019. |
| Ensure compatibility across platforms | Tested on Mac, Linux, and Windows 10. |
| Provide FORTRAN compiler compatibility | Recommends Intel or GNU Fortran compilers. |
| Enable users to compile the GCM | Includes instructions for modifying the Makefile and compiling the code using either GNU or Intel Fortran compilers. |
| Facilitate running the model | Instructions on copying the executable to the run/ directory and running the model using the provided mars_tutorial input file. |
| Support analysis of GCM output | Provides steps to compile and run a simple analysis routine (htest.f90) to check simulation outputs. |
| Maintain documentation and tutorial resources | Contains directories for documentation, source code, runtime data, analysis routines, and tutorial files. |
| Ensure end-of-life public release | The software is in its final release stage and will only receive critical bug fixes. |
Additional key aspects of this repository:
- Directory Structure:
documentation: Contains GCM documentation.code: Contains the GCM source code.run: Directory where the model is run, containing necessary input files.analysis: Contains a simple analysis routine and sample plots from default settings.tutorial: Contains files used in the tutorial.
- Licensing and Disclaimer:
- The software is provided "as is" without any warranty.
- Users must waive any claims against the United States Government and its contractors/subcontractors.
For further details, you can check the README.md file in the repository.
Invoking the Simulation
Here are the user actions, commands, and events that will trigger the functionality of simulating the Martian climate using the "NASA Ames Legacy Mars Global Climate Model" project:
User Actions and Commands
-
Clone the Repository:
git clone https://github.com/nasa/legacy-mars-global-climate-model.git cd legacy-mars-global-climate-model -
Navigate to the Source Code Directory:
cd code -
Modify the Makefile (if necessary):
- If using the Intel Fortran compiler (
ifort), update theMakefile:F90_COMP = ifort F_OPTS = -c -O2
- If using the Intel Fortran compiler (
-
Compile the Model:
- Clean previous builds:
make clean
- Compile the source code:
make
- This will create an executable file named
gcm2.3.
- Clean previous builds:
-
Prepare to Run the Model:
- Copy the executable to the
rundirectory:cp gcm2.3 ../run/ cd ../run/
- Copy the executable to the
-
Run the Model:
- Use the provided
mars_tutorialinput file:./gcm2.3 <mars_tutorial> m.out &
- Monitor the creation of output files (
fort.11,fort.51,fort.91) as the model runs.
- Use the provided
Key Files and Directories
- Source Code Directory (
code/): Contains all the FORTRAN source files needed to compile the GCM. - Run Directory (
run/): Where the executable (gcm2.3) is copied and the model is run. Contains necessary input files likemars_tutorial.
Events
- Compilation: Triggered by running the
makecommand in thecodedirectory. - Model Execution: Triggered by running the
./gcm2.3 <mars_tutorial> m.out &command in therundirectory.
For additional details, you can refer to the README.md file in the repository.
Entry point
The entrypoint program for invoking the simulation in the "NASA Ames Legacy Mars Global Climate Model" is the main.f source file, which contains the main subroutine that starts the simulation process.
Here is an overview of how you can identify the entrypoint in the Makefile:
-
Makefile Overview:
SRC = main.f input.f output.f comp3.f gmp.f sdet.f history.f\ emiss.f magfac.f init1.f insdet.f\ tempgr.f cmp3set.f gridvel.f potemp1.f potemp2.f convect.f\ cmp3out.f geopotn.f coldair.f getvdust.f jsrchgt.f90\ jsrchge.f90 mhistv.f mhisth.f gcmlog.f\ m4read.f bndcond.f descale.f eddycoef.f matrix.f scldef.f\ solve.f newpbl.f initpbl.f interpdust.f nextls.f dustprofile.f\ funcd.f newtg.f newstep.f dycore.f filters.f\ fallvel.f isource.f ssource.f initdt.f initcld.f sizedist.f\ radsetup.f90 optci.f90 optcv.f90 sfluxi.f90 sfluxv.f90\ setspi.f90 setspv.f90\ setrad.f90 tpindex.f90 dsolver.f90 gfluxi.f90 gfluxv.f90\ dtridgl.f90\ laginterp.f90 lagrange.f90 filltaucum.f fillpt.f90 dsolflux.f\ growthrate.f microphys.f opt_cld.f ddevil.f opt_dst.f\ getdetau.f90\ ini_optcld.f ini_optdst.f settozero.f solarza.f modules.f90
-
Main Source File:
- The
main.ffile is listed first in theSRCvariable, indicating it contains the main subroutine that serves as the entry point for the simulation.
- The
To summarize, the main.f file is the entrypoint program where the simulation starts. During the compilation process defined in the Makefile, all the source files, including main.f, are compiled to create the executable (gcm2.3), which is then used to run the simulation.
Logic in main.f
The main.f file of the "NASA Ames Legacy Mars Global Climate Model" serves as the entry point for the simulation. It initializes the model, reads input values, sets up the grid, and runs the time integration loop to compute atmospheric variables over time.
Purpose
- Initialize the model: Set up initial values and constants.
- Read input values: Determine whether to use previous run data or start from predefined values.
- Set up the grid: Represent the Martian atmosphere as a 3D grid.
- Run the time integration loop: Calculate atmospheric variables at regular time intervals.
Logic Flow
When the gcm2.3 executable is invoked, it follows the logic defined in main.f:
-
Program Initialization:
- Set control flags to default values.
- Call
RADSETUPto initialize radiation-related variables.
-
Input Handling:
- Call
INPUTto read input values and initialize grid points. - Check input validity and abort if necessary.
- Call
-
Main Time Step Loop:
- Start the next time step.
- Compute values for major variables.
- Call
NEWSTEPfor additional computations. - Perform various checks and history options.
- End the loop if the run is finished.
-
Program Termination:
- Write final values to the history tape.
- Stop the program.
Mermaid Flow Chart
Below is a Mermaid flow chart representing the logic flow of the main.f file:
graph TD
A[Program Initialization] --> B[Call RADSETUP]
B --> C[Call INPUT]
C --> D{Is Input Valid?}
D -- No --> E[Abort Program]
D -- Yes --> F[Main Time Step Loop]
F --> G[Start Next Time Step]
G --> H[Compute Values for Major Variables]
H --> I[Call NEWSTEP]
I --> J[Perform Checks and History Options]
J --> K{Is Run Finished?}
K -- No --> F
K -- Yes --> L[Write Final Values to History Tape]
L --> M[Stop Program]
This flow chart can be embedded in an issue to visually represent the logic flow of the main.f file when invoked by the gcm2.3 executable.