Skip to content

Convert this to typescript #1

@decyjphr

Description

@decyjphr

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

  1. Clone the Repository:

    git clone https://github.com/nasa/legacy-mars-global-climate-model.git
    cd legacy-mars-global-climate-model
  2. Navigate to the Source Code Directory:

    cd code
  3. Modify the Makefile (if necessary):

    • If using the Intel Fortran compiler (ifort), update the Makefile:
      F90_COMP = ifort
      F_OPTS   = -c -O2
  4. Compile the Model:

    • Clean previous builds:
      make clean
    • Compile the source code:
      make
    • This will create an executable file named gcm2.3.
  5. Prepare to Run the Model:

    • Copy the executable to the run directory:
      cp gcm2.3 ../run/
      cd ../run/
  6. Run the Model:

    • Use the provided mars_tutorial input file:
      ./gcm2.3 <mars_tutorial> m.out &
    • Monitor the creation of output files (fort.11, fort.51, fort.91) as the model runs.

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 like mars_tutorial.

Events

  • Compilation: Triggered by running the make command in the code directory.
  • Model Execution: Triggered by running the ./gcm2.3 <mars_tutorial> m.out & command in the run directory.

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:

  1. 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
  2. Main Source File:

    • The main.f file is listed first in the SRC variable, indicating it contains the main subroutine that serves as the entry point for the simulation.

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:

  1. Program Initialization:

    • Set control flags to default values.
    • Call RADSETUP to initialize radiation-related variables.
  2. Input Handling:

    • Call INPUT to read input values and initialize grid points.
    • Check input validity and abort if necessary.
  3. Main Time Step Loop:

    • Start the next time step.
    • Compute values for major variables.
    • Call NEWSTEP for additional computations.
    • Perform various checks and history options.
    • End the loop if the run is finished.
  4. 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]
Loading

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions