├── .gitignore ├── tests ├── valgrind.supp ├── python │ └── figures │ │ └── .gitkeep ├── carma_versiontest.F90 ├── bench │ ├── carma_vdry.txt │ ├── carma_fractalopticstest.txt │ ├── carma_cetest.txt │ ├── carma_growintest.txt │ ├── carma_growsubtest.txt │ └── carma_growclrtest.txt ├── read_coagtest.pro ├── carma_testutils.F90 ├── read_fractalopticstest.pro ├── read_falltest.pro ├── read_scfalltest.pro ├── read_vdiftest.pro ├── read_sigmafalltest.pro ├── read_mietest.pro ├── CMakeLists.txt ├── read_drydeptest.pro ├── read_sigmadrydeptest.pro ├── read_swelltest.pro ├── read_bcoctest.pro ├── carma_inittest.F90 ├── read_fractalmicrotest.pro ├── read_bc2gtest.pro ├── read_growtest.pro ├── carma_mietest.F90 ├── read_sulfatetest.pro ├── carma_fractalopticstest.F90 ├── read_pheattest.pro ├── read_growintest.pro ├── read_growsubtest.pro ├── read_nuc2test.pro ├── read_nuctest.pro ├── read_growclrtest.pro ├── nc_types_mod.F90 └── Makefile ├── .gitmodules ├── cmake ├── carmaConfig.cmake.in ├── cmake_uninstall.cmake.in ├── dependencies.cmake └── test_util.cmake ├── doc └── ChangeLog_template ├── Dockerfile ├── source ├── version.F90.in └── CMakeLists.txt ├── docker └── Dockerfile ├── bin └── f90doc-0.4.0 │ ├── LICENSE │ ├── README │ ├── utils.pl │ └── f90doc ├── .github └── workflows │ └── Ubuntu.yml ├── packaging └── CMakeLists.txt ├── make-carma.csh ├── CMakeLists.txt ├── view-bench.csh ├── run-all.csh ├── run-carma.csh ├── run-regress.csh └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /tests/valgrind.supp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/python/figures/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "source/base"] 2 | path = source/base 3 | url = https://github.com/ESCOMP/CARMA_base.git 4 | -------------------------------------------------------------------------------- /cmake/carmaConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/carma_Exports.cmake") 4 | 5 | check_required_components("@PROJECT_NAME@") -------------------------------------------------------------------------------- /tests/carma_versiontest.F90: -------------------------------------------------------------------------------- 1 | ! Copyright 2025 University Corporation for Atmospheric Research 2 | ! 3 | ! Simple test to check the CARMA version 4 | program test_carma_version 5 | use carma_version, only: get_carma_version 6 | 7 | implicit none 8 | 9 | ! Print the CARMA version 10 | write(*,*) "CARMA version: ", get_carma_version() 11 | 12 | end program test_carma_version -------------------------------------------------------------------------------- /doc/ChangeLog_template: -------------------------------------------------------------------------------- 1 | =============================================================== 2 | 3 | Tag name: 4 | Originator(s): 5 | Date: 6 | 7 | One-line Summary: 8 | 9 | Purpose of changes: 10 | 11 | Bugs fixed: 12 | 13 | List all subroutines eliminated: 14 | 15 | List all subroutines added and what they do: 16 | 17 | List all existing files that have been modified, and describe the changes: 18 | 19 | =============================================================== 20 | -------------------------------------------------------------------------------- /tests/bench/carma_vdry.txt: -------------------------------------------------------------------------------- 1 | 1 2.197645 2.055977 1.900814 1.839626 2 | 2.023491 2.289533 2.424854 2.471886 2.491353 3 | 2.509924 2.547552 2.642146 2.889431 3.541263 4 | 5.264271 9.825083 5 | 2 3.6529364E-05 6.1784602E-05 1.0698534E-04 1.9216446E-04 6 | 3.6408770E-04 7.3907047E-04 1.6156932E-03 3.7641148E-03 9.1727534E-03 7 | 2.3025157E-02 5.8950115E-02 0.1529059 0.3999489 1.051689 8 | 2.774663 7.335462 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:latest 2 | 3 | ARG BUILD_TYPE=Debug 4 | 5 | RUN dnf -y update \ 6 | && dnf -y install \ 7 | cmake \ 8 | gcc-c++ \ 9 | gfortran \ 10 | gdb \ 11 | git \ 12 | lapack-devel \ 13 | lcov \ 14 | make \ 15 | netcdf-fortran-devel \ 16 | python \ 17 | valgrind \ 18 | tree \ 19 | && dnf clean all 20 | 21 | # copy CARMA 22 | COPY . /carma/ 23 | 24 | # build CARMA 25 | RUN mkdir /build \ 26 | && cd /build \ 27 | && cmake \ 28 | -D CMAKE_BUILD_TYPE=${BUILD_TYPE} \ 29 | -D CARMA_ENABLE_MEMCHECK=ON \ 30 | /carma \ 31 | && make 32 | 33 | WORKDIR /build -------------------------------------------------------------------------------- /source/version.F90.in: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2025 University Corporation for Atmospheric Research 2 | ! SPDX-License-Identifier: Apache-2.0 3 | ! 4 | module carma_version 5 | implicit none 6 | 7 | private 8 | public :: get_carma_version 9 | 10 | contains 11 | 12 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 13 | 14 | function get_carma_version( ) result(version) 15 | ! Returns the CARMA version that is being built 16 | 17 | character(:), allocatable :: version 18 | 19 | version = "@carma_VERSION@" 20 | 21 | end function get_carma_version 22 | 23 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | 25 | end module carma_version -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:latest 2 | 3 | ARG BUILD_TYPE=Release 4 | ARG ENABLE_NETCDF=ON 5 | ARG ENABLE_MEMCHECK=OFF 6 | 7 | RUN dnf -y update \ 8 | && dnf -y install \ 9 | cmake \ 10 | gcc \ 11 | gcc-c++ \ 12 | gcc-fortran \ 13 | gdb \ 14 | git \ 15 | lapack-devel \ 16 | make \ 17 | netcdf-fortran-devel \ 18 | python3 \ 19 | python3-pip \ 20 | valgrind \ 21 | && dnf clean all 22 | 23 | ENV LD_LIBRARY_PATH=/usr/local/lib64 24 | 25 | # build CARMA 26 | COPY . /carma 27 | RUN mkdir build \ 28 | && cd build \ 29 | && cmake -D CMAKE_BUILD_TYPE=${BUILD_TYPE} \ 30 | -D CARMA_ENABLE_NETCDF=${ENABLE_NETCDF} \ 31 | -D CARMA_ENABLE_MEMCHECK=${ENABLE_MEMCHECK} \ 32 | -D CARMA_INSTALL_INCLUDE_DIR=/usr/local/include \ 33 | -D CARMA_INSTALL_MOD_DIR=/usr/local/include \ 34 | /carma \ 35 | && make install 36 | 37 | WORKDIR /build -------------------------------------------------------------------------------- /bin/f90doc-0.4.0/LICENSE: -------------------------------------------------------------------------------- 1 | f90doc is distributed according to the MIT License; see also 2 | http://www.opensource.org/licenses/mit-license.php 3 | 4 | Copyright (c) 1997-2006 Erik D. Demaine 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /tests/bench/carma_fractalopticstest.txt: -------------------------------------------------------------------------------- 1 | 1 10 1 2 | 1 0.118E-04 3 | 2 0.136E-04 4 | 3 0.197E-04 5 | 4 0.295E-04 6 | 5 0.413E-04 7 | 6 0.564E-04 8 | 7 0.689E-04 9 | 8 0.873E-04 10 | 9 0.102E-03 11 | 10 0.202E-03 12 | 1 0.232E-04 13 | 1 0.175E+01 0.400E+00 14 | 2 0.170E+01 0.270E+00 15 | 3 0.166E+01 0.220E+00 16 | 4 0.166E+01 0.150E+00 17 | 5 0.169E+01 0.760E-01 18 | 6 0.170E+01 0.230E-01 19 | 7 0.168E+01 0.880E-02 20 | 8 0.166E+01 0.240E-02 21 | 9 0.165E+01 0.100E-02 22 | 10 0.163E+01 0.720E-03 23 | 1 1 0.121E+02 0.419E+00 0.902E+00 0.234E+01 0.523E+00 0.893E+00 24 | 2 1 0.122E+02 0.472E+00 0.887E+00 0.238E+01 0.507E+00 0.903E+00 25 | 3 1 0.107E+02 0.551E+00 0.827E+00 0.249E+01 0.484E+00 0.898E+00 26 | 4 1 0.720E+01 0.714E+00 0.709E+00 0.263E+01 0.486E+00 0.798E+00 27 | 5 1 0.398E+01 0.838E+00 0.672E+00 0.355E+01 0.732E+00 0.719E+00 28 | 6 1 0.169E+01 0.926E+00 0.662E+00 0.425E+01 0.926E+00 0.684E+00 29 | 7 1 0.870E+00 0.957E+00 0.653E+00 0.301E+01 0.971E+00 0.581E+00 30 | 8 1 0.405E+00 0.981E+00 0.632E+00 0.211E+01 0.989E+00 0.597E+00 31 | 9 1 0.253E+00 0.989E+00 0.612E+00 0.116E+01 0.995E+00 0.508E+00 32 | 10 1 0.342E-01 0.972E+00 0.434E+00 0.976E-01 0.987E+00 0.108E+00 33 | -------------------------------------------------------------------------------- /.github/workflows/Ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref || github.run_id }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | build-and-test: 16 | runs-on: ubuntu-latest 17 | continue-on-error: true 18 | strategy: 19 | matrix: 20 | compiler: 21 | - { cpp: g++-12, c: gcc-12} 22 | - { cpp: g++-13, c: gcc-13} 23 | - { cpp: g++-14, c: gcc-14} 24 | build_type: [Release, Debug] 25 | enable_netcdf: [ON, OFF] 26 | env: 27 | CC: ${{ matrix.compiler.c }} 28 | CXX: ${{ matrix.compiler.cpp }} 29 | steps: 30 | - name: Checkout code 31 | uses: actions/checkout@v4 32 | 33 | - name: Run Cmake 34 | run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D CARMA_ENABLE_NETCDF=${{ matrix.enable_netcdf }} -D CARMA_ENABLE_MEMCHECK=ON -D CMAKE_POLICY_VERSION_MINIMUM=3.5 35 | 36 | - name: Build 37 | run: cmake --build build --config ${{ matrix.build_type }} --parallel 10 38 | 39 | - name: Run tests 40 | run: | 41 | cd build 42 | ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake 2 | 3 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 5 | endif() 6 | 7 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 8 | string(REGEX REPLACE "\n" ";" files "${files}") 9 | foreach(file ${files}) 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program( 13 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 14 | OUTPUT_VARIABLE rm_out 15 | RETURN_VALUE rm_retval 16 | ) 17 | if(NOT "${rm_retval}" STREQUAL 0) 18 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 19 | endif() 20 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 22 | endif() 23 | endforeach() 24 | 25 | set(uninstall_dirs "@INSTALL_PREFIX@;@cmake_config_install_location@") 26 | 27 | foreach(dir IN LISTS uninstall_dirs) 28 | message(STATUS "Uninstalling ${dir}") 29 | exec_program( 30 | "@CMAKE_COMMAND@" ARGS "-E remove_directory ${dir}" 31 | OUTPUT_VARIABLE rm_out 32 | RETURN_VALUE rm_retval 33 | ) 34 | if(NOT "${rm_retval}" STREQUAL 0) 35 | message(FATAL_ERROR "Problem when removing ${dir}") 36 | endif() 37 | endforeach() -------------------------------------------------------------------------------- /bin/f90doc-0.4.0/README: -------------------------------------------------------------------------------- 1 | This is f90doc version 0.4.0, a documentation tool for Fortran 90. For 2 | more information (e.g., documentation), see 3 | 4 | http://theory.lcs.mit.edu/~edemaine/f90doc 5 | 6 | or contact Erik Demaine (edemaine@mit.edu). Comments, suggestions, 7 | criticisms, and bug reports go to this e-mail address. If you modify f90doc or 8 | use it in a serious way, please contact me (I'd be interested). 9 | 10 | COPYRIGHT 11 | 12 | f90doc is freeware. If you use it in a research or commercial project, you 13 | must acknowledge the software and its author. I would also appreciate it if 14 | you contact me -- I'd like to know how f90doc is used. If you base code on 15 | f90doc, you must acknowledge this. Again, please let me know if you think your 16 | changes would be at all useful to the rest of the world (even if you are not 17 | willing to share it, the ideas may be useful). 18 | 19 | This information must accompany any copy of f90doc. 20 | 21 | INSTALLATION 22 | 23 | You shouldn't have to compile anything. You can put the file f90doc in 24 | a more accessible place, but the .pl files have to be in the same directory. 25 | Alternatively, you can create a symlink to the real f90doc, where the .pl 26 | files are held. For example, 27 | 28 | ln -s /usr/local/lib/f90doc-0.4.0/f90doc /usr/local/bin/f90doc 29 | 30 | If you don't have a command /usr/bin/env, you'll need to replace the first line 31 | of f90doc with 32 | 33 | #!/path/to/perl5/bin/perl -w 34 | 35 | Otherwise, Perl version 5.003 or higher must be the first program called "perl" 36 | in your path. 37 | -------------------------------------------------------------------------------- /bin/f90doc-0.4.0/utils.pl: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | use strict; 4 | 5 | sub copy_list { 6 | my ($listref) = @_; 7 | my @list; 8 | @list = @$listref; 9 | \@list; 10 | } 11 | 12 | sub copy_hash { 13 | my ($hashref) = @_; 14 | my %hash; 15 | %hash = %$hashref; 16 | \%hash; 17 | } 18 | 19 | sub hash2str { 20 | my ($hash) = @_; 21 | my ($key, $s); 22 | $s = "{\n"; 23 | foreach $key (keys %$hash) { 24 | $s .= " $key => $hash->{$key}\n"; 25 | } 26 | $s .= "}"; 27 | } 28 | 29 | sub trim { 30 | my ($s) = @_; 31 | $s =~ s/^\s*//; 32 | $s =~ s/\s*$//; 33 | $s; 34 | } 35 | 36 | # balsplit (sep, string) splits string into pieces divided by sep when 37 | # sep is "outside" ()s. Returns a list just like split. 38 | sub balsplit { 39 | my ($sep, $str) = @_; 40 | my ($i, $c); 41 | my ($len, $level, $left) = (length ($str), 0, 0); 42 | my (@list) = (); 43 | 44 | for ($i = 0; $i < $len; $i++) { 45 | $c = substr ($str, $i, 1); 46 | if ($c eq "(") { 47 | $level++; 48 | } elsif ($c eq ")") { 49 | $level--; 50 | die "balsplit: Unbalanced parens (too many )'s)" if $level < 0; 51 | } elsif ($c eq $sep && $level == 0) { 52 | push (@list, substr ($str, $left, $i-$left)); 53 | $left = $i + 1; 54 | } 55 | } 56 | 57 | push (@list, substr ($str, $left)); 58 | return @list; 59 | } 60 | 61 | # Takes the first word of each element of the list. 62 | sub leftword { 63 | my ($listref) = @_; 64 | my @out = (); 65 | my ($x); 66 | foreach $x (@$listref) { 67 | $x =~ s/^\s*//; 68 | $x =~ /^\w*/; 69 | push (@out, $&); 70 | } 71 | @out; 72 | } 73 | 74 | sub remove_blanks { 75 | my ($listref) = @_; 76 | my @out = (); 77 | my ($x); 78 | foreach $x (@$listref) { 79 | push (@out, $x) unless $x =~ /^\s*$/; 80 | } 81 | @out; 82 | } 83 | 84 | sub do_nothing { 85 | } 86 | 87 | 1; 88 | -------------------------------------------------------------------------------- /packaging/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | # install the binary and static library 4 | install( 5 | TARGETS 6 | carma carma_object 7 | EXPORT 8 | carma_Exports 9 | LIBRARY DESTINATION ${INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} 10 | ARCHIVE DESTINATION ${INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} 11 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 12 | ) 13 | 14 | # install the mod files 15 | install( 16 | DIRECTORY 17 | ${CARMA_MOD_DIR}/ 18 | DESTINATION 19 | ${CARMA_INSTALL_MOD_DIR} 20 | FILES_MATCHING PATTERN "*.mod" 21 | ) 22 | 23 | # install the cmake config files 24 | set(cmake_config_install_location ${INSTALL_PREFIX}/cmake/carma-${PROJECT_VERSION}) 25 | 26 | install( 27 | EXPORT 28 | carma_Exports 29 | DESTINATION 30 | ${cmake_config_install_location} 31 | NAMESPACE musica:: 32 | ) 33 | 34 | configure_package_config_file( 35 | "${PROJECT_SOURCE_DIR}/cmake/carmaConfig.cmake.in" 36 | "${PROJECT_BINARY_DIR}/carmaConfig.cmake" 37 | INSTALL_DESTINATION 38 | ${cmake_config_install_location} 39 | ) 40 | 41 | write_basic_package_version_file( 42 | "${PROJECT_BINARY_DIR}/carmaConfigVersion.cmake" 43 | VERSION ${PROJECT_VERSION} 44 | COMPATIBILITY SameMajorVersion 45 | ) 46 | 47 | install( 48 | FILES 49 | ${PROJECT_BINARY_DIR}/carmaConfig.cmake 50 | ${PROJECT_BINARY_DIR}/carmaConfigVersion.cmake 51 | DESTINATION 52 | ${INSTALL_PREFIX}/cmake/carma-${PROJECT_VERSION} 53 | ) 54 | 55 | ###################################################################### 56 | # uninstall target 57 | 58 | # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake 59 | if(NOT TARGET uninstall) 60 | configure_file( 61 | "${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" 62 | "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" 63 | IMMEDIATE @ONLY) 64 | 65 | add_custom_target(uninstall 66 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 67 | endif() -------------------------------------------------------------------------------- /make-carma.csh: -------------------------------------------------------------------------------- 1 | #! /bin/tcsh -f 2 | 3 | # An entry point for build the CARMA code, which creates the build directory 4 | # and populates it with the base makefile. 5 | # 6 | # NOTE: This script could be easily enhanced to manage multiple targets and 7 | # multiple build directories, which may be useful as part of an automated test 8 | # suite. 9 | # 10 | # Usage 11 | # make-carma.csh [build target] 12 | # 13 | # build target - target label for the make 14 | # 15 | # Environment Variables 16 | # CARMA_BUILD [carma] 17 | # The subdirectory in which the build will be performed. 18 | 19 | # Look for gmake first, but if not found then just use make. 20 | setenv MAKETOOL "`which gmake`" 21 | echo $MAKETOOL 22 | if ("`echo $MAKETOOL | grep 'not found'`" != "") then 23 | setenv MAKETOOL "`which make`" 24 | endif 25 | 26 | echo "Using : " $MAKETOOL 27 | echo "" 28 | 29 | # By default, build all of the targets in a directory named build. 30 | set bldtgt=all 31 | 32 | if ($# == 1) then 33 | set bldtgt="$1" 34 | endif 35 | 36 | if (! $?CARMA_BUILD ) then 37 | setenv CARMA_BUILD carma 38 | endif 39 | 40 | set blddir=build/$CARMA_BUILD 41 | set docdir=doc/f90doc 42 | 43 | # Create a directory for the build. 44 | echo "Building the target $bldtgt in the directory $blddir" 45 | mkdir -p $blddir 46 | 47 | # Copy the makefile to the build directory. 48 | cp Makefile $blddir/Makefile 49 | 50 | # In MacOSX, the tar command will try to store off the resource fork as an 51 | # extra file which is the same name as the original file with a ._ prefix. 52 | # This flag stops that behavior 53 | if ($bldtgt == tar) then 54 | setenv COPYFILE_DISABLE TRUE 55 | endif 56 | 57 | # Execute the make file in the build directory. 58 | cd $blddir 59 | $MAKETOOL $bldtgt 60 | 61 | # Create the documentation. 62 | if ($bldtgt != tar) then 63 | echo "Creating the documentation in the directory $docdir" 64 | 65 | # Create a directory for the build. 66 | cd ../.. 67 | mkdir -p $docdir 68 | 69 | # Copy the makefile to the doc directory. 70 | cp Makefile $docdir/Makefile 71 | 72 | cd $docdir 73 | $MAKETOOL doc 74 | endif 75 | 76 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | 3 | project( 4 | carma 5 | VERSION 4.0.0 6 | LANGUAGES Fortran CXX C 7 | ) 8 | 9 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) 10 | set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake") 11 | 12 | if(NOT CMAKE_BUILD_TYPE) 13 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING 14 | "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." 15 | FORCE) 16 | endif(NOT CMAKE_BUILD_TYPE) 17 | 18 | message ( STATUS "CMake build configuration for carma(${CMAKE_BUILD_TYPE}) ${PROJECT_VERSION}" ) 19 | 20 | ################################################################################ 21 | # Project wide setup options 22 | 23 | option(CARMA_ENABLE_MEMCHECK "Enable memory checking in tests" OFF) 24 | option(CARMA_ENABLE_NETCDF "Enable NetCDF support" ON) 25 | 26 | set(CARMA_MOD_DIR "${PROJECT_BINARY_DIR}/include" CACHE PATH "Directory to find Fortran module files during build") 27 | set(CARMA_INSTALL_MOD_DIR "${INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Directory to install Fortran module files") 28 | set(CARMA_INSTALL_INCLUDE_DIR "${INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Directory to install CARMA include files") 29 | 30 | # Set up include and lib directories 31 | set(CARMA_LIB_DIR "${PROJECT_BINARY_DIR}/lib") 32 | include(GNUInstallDirs) 33 | set(INSTALL_PREFIX "carma-${PROJECT_VERSION}") 34 | 35 | ################################################################################ 36 | # Dependencies 37 | 38 | include(cmake/dependencies.cmake) 39 | 40 | ################################################################################ 41 | # CAMRA targets 42 | 43 | add_subdirectory(source) 44 | 45 | ################################################################################ 46 | # Packaging 47 | 48 | # Only include pacakaging if we are the top-level project 49 | if(PROJECT_IS_TOP_LEVEL) 50 | add_subdirectory(packaging) 51 | endif() 52 | 53 | ################################################################################ 54 | # Tests 55 | 56 | if(PROJECT_IS_TOP_LEVEL) 57 | enable_testing() 58 | add_subdirectory(tests) 59 | endif() 60 | -------------------------------------------------------------------------------- /cmake/dependencies.cmake: -------------------------------------------------------------------------------- 1 | find_package(PkgConfig REQUIRED) 2 | include(FetchContent) 3 | 4 | ################################################################################## 5 | # LAPACK 6 | 7 | # Try to find BLAS first, then LAPACK 8 | # Use shared libraries preference to avoid static library issues 9 | set(BLA_STATIC OFF) 10 | find_package(BLAS REQUIRED) 11 | find_package(LAPACK REQUIRED) 12 | 13 | # ############################################################################## 14 | # Memory check 15 | 16 | if(CARMA_ENABLE_MEMCHECK) 17 | find_file( 18 | MEMCHECK_SUPPRESS_FILE 19 | DOC "Suppression file for memory checking" 20 | NAMES openmpi-valgrind.supp 21 | PATHS /usr/share/openmpi /usr/lib64/openmpi/share 22 | /usr/lib64/openmpi/share/openmpi /usr/share) 23 | if(MEMCHECK_SUPPRESS_FILE) 24 | set(MEMCHECK_SUPPRESS 25 | "--suppressions=${PROJECT_SOURCE_DIR}/tests/valgrind.supp --suppressions=${MEMCHECK_SUPPRESS_FILE}" 26 | ) 27 | else() 28 | set(MEMCHECK_SUPPRESS 29 | "--suppressions=${PROJECT_SOURCE_DIR}/tests/valgrind.supp") 30 | endif() 31 | endif() 32 | 33 | ################################################################################## 34 | # NetCDF 35 | 36 | if(CARMA_ENABLE_NETCDF) 37 | find_package(PkgConfig REQUIRED) 38 | 39 | pkg_check_modules(netcdff REQUIRED IMPORTED_TARGET netcdf-fortran) 40 | pkg_check_modules(netcdfc REQUIRED IMPORTED_TARGET netcdf) 41 | 42 | # Get the include directories from pkg-config 43 | execute_process( 44 | COMMAND pkg-config --variable=includedir netcdf-fortran 45 | OUTPUT_VARIABLE NETCDF_FORTRAN_INCLUDE_DIR 46 | OUTPUT_STRIP_TRAILING_WHITESPACE 47 | ) 48 | 49 | # Add the include directory to the project 50 | include_directories(${NETCDF_FORTRAN_INCLUDE_DIR}) 51 | endif() 52 | 53 | ################################################################################## 54 | # Google Test 55 | 56 | if(PROJECT_IS_TOP_LEVEL) 57 | FetchContent_Declare( 58 | googletest 59 | GIT_REPOSITORY https://github.com/google/googletest.git 60 | GIT_TAG be03d00f5f0cc3a997d1a368bee8a1fe93651f48) 61 | 62 | set(INSTALL_GTEST 63 | OFF 64 | CACHE BOOL "" FORCE) 65 | set(BUILD_GMOCK 66 | OFF 67 | CACHE BOOL "" FORCE) 68 | 69 | FetchContent_MakeAvailable(googletest) 70 | endif() 71 | -------------------------------------------------------------------------------- /tests/read_coagtest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_coagtest.txt', /get_lun 2 | readf, lun, nbin, nelem, ngroup 3 | 4 | ; ibin_ = intarr(nbin) 5 | r = fltarr(nbin,ngroup) ; radius (cm) 6 | dr = fltarr(nbin,ngroup) ; delta radius (cm) 7 | data = fltarr(3) 8 | 9 | for igroup = 0, ngroup-1 do begin 10 | for ibin = 0, nbin-1 do begin 11 | readf, lun, data 12 | ; ibin_[ibin] = fix( data[0] ) 13 | r[ibin,igroup] = data[1] 14 | dr[ibin,igroup] = data[2] 15 | endfor 16 | endfor 17 | 18 | data2 = fltarr(2) 19 | pc_ = fltarr(nbin,nelem) ; number (#/cm^-3) in a bin 20 | 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | 26 | for ielem = 0, nelem-1 do begin 27 | for ibin = 0, nbin-1 do begin 28 | readf, lun, data2 29 | ; ibin_[ibin] = fix( data2[0] ) 30 | pc_[ibin,ielem] = data2[1] 31 | endfor 32 | endfor 33 | 34 | ; ibin = [ibin,ibin_] 35 | if (t1 eq 0.) then begin 36 | pc = pc_ 37 | time = t1 38 | endif else begin 39 | pc = [pc,pc_] 40 | time = [time,t1] 41 | endelse 42 | 43 | nt = nt+1 44 | endwhile 45 | 46 | free_lun, lun 47 | 48 | pc = reform(pc,nbin,nt,nelem) 49 | 50 | 51 | ; Map units for this test 52 | ; 4 elements: 1 - BC, 2 - OC, 3 - OC shell, 4 - BC core 53 | ; Elements 1 - 3 are PC; element 4 is COREMASS 54 | ; For now, all elements have same size and mass dimensions 55 | d = 2.*r*1e4 56 | dd = 2.*dr*1e4 57 | 58 | dnlogd = alog(10.) * pc 59 | 60 | for ibin = 0, nbin-1 do begin 61 | dnlogd[ibin,*,0] = dnlogd[ibin,*,0]*d[ibin,0]/dd[ibin,0] 62 | endfor 63 | 64 | ; Can't display 0 in log coordinates 65 | dnlogd[where(dnlogd le 0.)] = !Values.F_NAN 66 | 67 | 68 | 69 | ; The data has been manipulated and converted to match Figure 2 from 70 | ; Jacobson et al., Atmospheric Environment 28, 1327-1338, 1994 71 | ; Initial monodisperse distribution is slightly different -- probably because 72 | ; I don't know what bin edges were used to calculate dr 73 | ; 74 | ; - JAS, August 15, 2007 75 | 76 | plot, [ 0.005, 0.1 ], [ 1., 1.e8 ], /nodata $ 77 | , xtitle = 'Diameter (um)' $ 78 | , /xlog, xstyle = 1 $ 79 | , ytitle = 'dN / d log D (cm-3)' $ 80 | , /ylog, ystyle = 1 $ 81 | , charsize = 1.25 82 | oplot, d, dnlogd[*,0,0], psym=2, symsize=1.25 83 | oplot, d, dnlogd[*,nt-1,0], lin=2 84 | 85 | end 86 | -------------------------------------------------------------------------------- /view-bench.csh: -------------------------------------------------------------------------------- 1 | #! /bin/tcsh -f 2 | # An entry point for viewing the results of the benchmark runs that 3 | # are part of the CARMA distribution. 4 | # 5 | # Usage 6 | # view-bench.csh [view target] 7 | # 8 | # build target - target label for the make 9 | # 10 | 11 | # Environment Variables 12 | # CARMA_BUILD [carma] 13 | # The subdirectory in which the build was performed. 14 | 15 | if (! $?CARMA_IDL ) then 16 | setenv CARMA_IDL /Applications/itt/idl70/bin/idl 17 | endif 18 | 19 | set runtgt=CARMATEST.exe 20 | 21 | if ($# == 1) then 22 | set runtgt="$1" 23 | endif 24 | 25 | set rundir=run/bench 26 | set testdir=tests 27 | set idlfile="read_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.pro" 28 | set outfile="carma_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.txt" 29 | 30 | echo $idlfile 31 | echo $outfile 32 | 33 | # Create a directory for the build. 34 | echo "Viewing $testdir/bench/$outfile in the directory $rundir ..." 35 | mkdir -p $rundir 36 | 37 | # Copy the benchmark result to the run directory. 38 | cp $testdir/bench/$outfile $rundir 39 | 40 | if (-f $testdir/$idlfile) then 41 | 42 | # Don't overwrite the file in the run directory if it is newer than 43 | # the one in the test directory. 44 | # 45 | # NOTE: For the test on modification date to work, the copy must 46 | # preserve the modify date and time. 47 | if (-f $rundir/$idlfile) then 48 | if (-M "$rundir/$idlfile" > -M "$testdir/$idlfile") then 49 | setenv IDL_WARNING " WARNING: $idlfile not copied, since $rundir/$idlfile is newer than $testdir/$idlfile" 50 | else 51 | cp -p $testdir/$idlfile $rundir 52 | endif 53 | else 54 | cp -p $testdir/$idlfile $rundir 55 | endif 56 | endif 57 | 58 | # Execute the make file in the build directory. 59 | cd $rundir 60 | 61 | if (-f $idlfile) then 62 | 63 | if (-f $outfile) then 64 | echo "" 65 | echo "Running the IDL analysis routine $idlfile" 66 | 67 | if ($?IDL_WARNING) then 68 | echo "" 69 | echo "$IDL_WARNING" 70 | echo "" 71 | endif 72 | 73 | echo " To run the test, in IDL you need to type the command: .r $idlfile" 74 | echo " To exit IDL, type the command: exit" 75 | 76 | # NOTE: If your invokation of IDL fails, check to see whether idl 77 | # is really on you path or if it is just an alias. Aliases don't work 78 | # properly in scripts, but this is how IDL is setup be default. You 79 | # can add the idl bin directory to your path so that this will work. 80 | echo "" 81 | $CARMA_IDL 82 | endif 83 | endif 84 | 85 | 86 | -------------------------------------------------------------------------------- /run-all.csh: -------------------------------------------------------------------------------- 1 | #! /bin/tcsh -f 2 | # An entry point for running all of the carma tests. It creates a run directory 3 | # copies in the executables and then runs all of the test executables. 4 | # 5 | # 6 | # Usage 7 | # run-carma.csh 8 | 9 | # Environment Variables 10 | # CARMA_BUILD [carma] 11 | # The subdirectory in which the build was performed. 12 | 13 | # By default, run the single column model 14 | if (! $?CARMA_BUILD ) then 15 | setenv CARMA_BUILD carma 16 | endif 17 | 18 | if (! $?CARMA_CASE ) then 19 | setenv CARMA_CASE $CARMA_BUILD 20 | endif 21 | 22 | if (! $?CARMA_THREADS ) then 23 | setenv CARMA_THREADS 1 24 | endif 25 | 26 | if (! $?CARMA_IDL ) then 27 | setenv CARMA_IDL idl 28 | endif 29 | 30 | set runtgt=CARMATEST.exe 31 | 32 | if ($# == 1) then 33 | set runtgt="$1" 34 | endif 35 | 36 | set blddir=build/$CARMA_BUILD 37 | set rundir=run/$CARMA_CASE 38 | set testdir=tests 39 | 40 | # Create a directory for the build. 41 | mkdir -p $rundir 42 | 43 | # Copy the executable to the run directory. 44 | cp $blddir/*TEST.exe $rundir 45 | 46 | 47 | # Prepare for multiple threads, assuming Intel Compiler. 48 | setenv OMP_NUM_THREADS $CARMA_THREADS 49 | setenv KMP_STACKSIZE 128M 50 | 51 | # Execute the tests. 52 | cd $rundir 53 | 54 | echo `ls -1 *TEST.exe` 55 | foreach runtgt (`ls -1 *TEST.exe`) 56 | echo " ** Started $runtgt at `date` **" 57 | ./$runtgt || echo ' *** Run Failed ***' && exit -1 58 | echo " ** Finished at `date` **" 59 | echo "" 60 | 61 | set idlfile="read_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.pro" 62 | set outfile="carma_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.txt" 63 | 64 | if (! -f $idlfile) then 65 | cp -p ../../$testdir/$idlfile . 66 | endif 67 | 68 | if (-f $idlfile) then 69 | 70 | if (-f $outfile) then 71 | echo "" 72 | echo "Running the IDL analysis routine $idlfile" 73 | 74 | if ($?IDL_WARNING) then 75 | echo "" 76 | echo "$IDL_WARNING" 77 | echo "" 78 | endif 79 | 80 | echo " To run the test, in IDL you need to type the command: .r $idlfile" 81 | echo " To exit IDL, type the command: exit" 82 | 83 | # NOTE: If your invokation of IDL fails, check to see whether idl 84 | # is really on you path or if it is just an alias. Aliases don't work 85 | # properly in scripts, but this is how IDL is setup be default. You 86 | # can add the idl bin directory to your path so that this will work. 87 | echo "" 88 | $CARMA_IDL 89 | endif 90 | endif 91 | end 92 | 93 | 94 | -------------------------------------------------------------------------------- /tests/carma_testutils.F90: -------------------------------------------------------------------------------- 1 | !! Some common utilities used in the CARMA test code. 2 | !! 3 | !! @author Chuck Bardeen 4 | !! @version Jun-2010 5 | 6 | 7 | subroutine dumpElement(carma, rc) 8 | use carma_precision_mod 9 | use carma_enums_mod 10 | use carma_types_mod 11 | use carmaelement_mod 12 | use carma_mod 13 | 14 | implicit none 15 | 16 | type(carma_type), intent(in) :: carma !! the carma object 17 | integer, intent(inout) :: rc !! return code, negative indicates failure 18 | 19 | ! Local Variables 20 | integer :: i 21 | integer :: NELEM 22 | 23 | write(*,*) "" 24 | write(*,*) "Element Information" 25 | 26 | call CARMA_Get(carma, rc, NELEM=NELEM) 27 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 28 | 29 | do i = 1, NELEM 30 | call CARMAELEMENT_Print(carma, i, rc) 31 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 32 | 33 | write(*,*) "" 34 | end do 35 | 36 | write(*,*) "" 37 | return 38 | end subroutine 39 | 40 | 41 | subroutine dumpGas(carma, rc) 42 | use carma_precision_mod 43 | use carma_enums_mod 44 | use carma_types_mod 45 | use carmagas_mod 46 | use carma_mod 47 | 48 | implicit none 49 | 50 | type(carma_type), intent(in) :: carma !! the carma object 51 | integer, intent(inout) :: rc !! return code, negative indicates failure 52 | 53 | ! Local Variables 54 | integer :: i 55 | integer :: NGAS 56 | 57 | call CARMA_Get(carma, rc, NGAS=NGAS) 58 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 59 | 60 | write(*,*) "" 61 | write(*,*) "Gas Information" 62 | 63 | do i = 1, NGAS 64 | call CARMAGAS_Print(carma, i, rc) 65 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 66 | 67 | write(*,*) "" 68 | end do 69 | 70 | write(*,*) "" 71 | end subroutine 72 | 73 | 74 | subroutine dumpGroup(carma, rc) 75 | use carma_precision_mod 76 | use carma_enums_mod 77 | use carma_types_mod 78 | use carmagroup_mod 79 | use carma_mod 80 | 81 | implicit none 82 | 83 | type(carma_type), intent(in) :: carma !! the carma object 84 | integer, intent(inout) :: rc !! return code, negative indicates failure 85 | 86 | ! Local Variables 87 | integer :: i 88 | integer :: NGROUP 89 | 90 | write(*,*) "" 91 | write(*,*) "Group Information" 92 | 93 | call CARMA_Get(carma, rc, NGROUP=NGROUP) 94 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 95 | 96 | do i = 1, NGROUP 97 | call CARMAGROUP_Print(carma, i, rc) 98 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 99 | 100 | write(*,*) "" 101 | end do 102 | 103 | write(*,*) "" 104 | return 105 | end subroutine 106 | -------------------------------------------------------------------------------- /tests/read_fractalopticstest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_fractalopticstest.txt', /get_lun 2 | 3 | 4 | ; Read in the wavelengths. 5 | readf, lun, NGROUP, NWAVE, NBIN 6 | 7 | wave = fltarr(NWAVE) 8 | 9 | data = fltarr(2) 10 | 11 | for iwave = 0, NWAVE-1 do begin 12 | readf, lun, data 13 | 14 | wave[iwave] = data[1] 15 | endfor 16 | 17 | 18 | ; Read in the radius, refractive index and optical properties. 19 | r = fltarr(NBIN,NGROUP) 20 | refidx = fltarr(NWAVE,NGROUP) 21 | 22 | qext_fractal = fltarr(NWAVE,NGROUP,NBIN) 23 | ssa_fractal = fltarr(NWAVE,NGROUP,NBIN) 24 | asym_fractal = fltarr(NWAVE,NGROUP,NBIN) 25 | 26 | qext_sphere = fltarr(NWAVE,NGROUP,NBIN) 27 | ssa_sphere = fltarr(NWAVE,NGROUP,NBIN) 28 | asym_sphere = fltarr(NWAVE,NGROUP,NBIN) 29 | 30 | for igroup = 0, NGROUP-1 do begin 31 | data = fltarr(2) 32 | 33 | for ibin = 0, NBIN-1 do begin 34 | readf, lun, data 35 | r(ibin, igroup) = data[1] 36 | endfor 37 | 38 | data = fltarr(3) 39 | 40 | for iwave = 0, NWAVE-1 do begin 41 | readf, lun, data 42 | endfor 43 | 44 | data = fltarr(8) 45 | 46 | for iwave = 0, NWAVE-1 do begin 47 | for ibin = 0, NBIN-1 do begin 48 | readf, lun, data 49 | ;print, wave(iwave)*1.0e4,iwave, ibin, data 50 | 51 | qext_fractal(iwave, igroup, ibin) = data[2] 52 | ssa_fractal(iwave, igroup, ibin) = data[3] 53 | asym_fractal(iwave, igroup, ibin) = data[4] 54 | qext_sphere(iwave, igroup, ibin) = data[5] 55 | ssa_sphere(iwave, igroup, ibin) = data[6] 56 | asym_sphere(iwave, igroup, ibin) = data[7] 57 | endfor 58 | endfor 59 | endfor 60 | 61 | free_lun, lun 62 | wave(*) = wave(*) * 1.0e4 63 | 64 | ; Plot qext, ssa and asym 65 | !p.multi=[0,1,3] 66 | loadct, 39 67 | 68 | plot, wave(*), qext_fractal(*,0,0), yrange=[0,26], xrange=[0.0,1.0], $ 69 | title = 'Extinction Efficiency', $ 70 | xtitle='Wavelength [um]', ytitle = 'Qext', thick=2, charsize=2.0, /nodata 71 | oplot, wave(*), qext_fractal(*,0,0), linestyle=0,color=200, thick=2.0 72 | oplot, wave(*), qext_sphere(*,0,0), linestyle=0, thick=2.0 73 | xyouts, 0.66,0.92, "For Titan hydrocarbon hazes",/NORMAL, charsize=1.1 74 | xyouts, 0.75,0.89, "Fractal", color=200, /NORMAL 75 | xyouts, 0.75,0.86, "Sphere", /NORMAL 76 | 77 | 78 | plot, wave(*), ssa_fractal[*,0,0], yrange=[0,1], xrange=[0.0,1.0], $ 79 | title = 'Single Scattering Albedo', $ 80 | xtitle='Wavelength [um]', ytitle = 'w', thick=2, charsize=2.0, linestyle=2, /nodata 81 | oplot, wave(*), ssa_fractal(*,0,0), linestyle=0, color=200, thick=2.0 82 | oplot, wave(*), ssa_sphere(*,0,0), linestyle=0, thick=2.0 83 | 84 | plot, wave(*), asym_fractal[*,0,0], yrange=[-1.05,1.05], xrange=[-0.0,1.0], ystyle=1, $ 85 | title = 'Asymmetry Factor', $ 86 | xtitle='Wavelength [um]', ytitle = 'g', thick=2, charsize=2.0, linestyle=2, /nodata 87 | oplot, wave(*), asym_fractal(*,0,0),linestyle=0, color=200, thick=2.0 88 | oplot, wave(*), asym_sphere(*,0,0),linestyle=0, thick=2.0 89 | 90 | end 91 | -------------------------------------------------------------------------------- /tests/read_falltest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_falltest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz 5 | 6 | z = fltarr(nz) 7 | dz = fltarr(nz) 8 | 9 | data = fltarr(3) 10 | 11 | for iz = 0, nz-1 do begin 12 | readf, lun, data 13 | 14 | z[iz] = data[1] 15 | dz[iz] = data[2] 16 | endfor 17 | 18 | ; Read in the particles for each time step. 19 | mmr_ = fltarr(nz) 20 | q_ = fltarr(nz) 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | 26 | for iz = 0, nz-1 do begin 27 | readf, lun, data 28 | 29 | mmr_[iz] = data[1] 30 | q_[iz] = data[2] 31 | endfor 32 | 33 | if (nt eq 0) then begin 34 | time = t1 35 | mmr = mmr_ 36 | q = q_ 37 | endif else begin 38 | time = [time,t1] 39 | mmr = [mmr,mmr_] 40 | q = [q,q_] 41 | endelse 42 | 43 | nt = nt+1 44 | endwhile 45 | 46 | free_lun, lun 47 | 48 | mmr = reform(mmr,nz,nt) 49 | q = reform(q,nz,nt) 50 | 51 | z = z/1000. 52 | 53 | !p.multi = [0,1,2] 54 | loadct, 39 55 | 56 | ;Calculate the column mass, which should be conserved. 57 | mass = fltarr(nt) 58 | 59 | for it = 0, nt-1 do begin 60 | mass[it] = total(q[*,it]*dz[*]) 61 | endfor 62 | 63 | print 64 | 65 | for it = 0, nt-1 do begin 66 | plot, q[*,0], z[*], yrange=[0,11], xrange=[0,2.5e-10], $ 67 | title = 'time = '+string(time[it])+' seconds', $ 68 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 69 | oplot, q[*,it], z[*], lin=2, thick=3, color=66 70 | 71 | ; Show the mass evolution. 72 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 73 | title = 'Total mass evolution' 74 | oplot, mass[0:it], thick=6, color=66, lin=0 75 | 76 | wait, 0.01 77 | endfor 78 | 79 | plot, q[*,0], z[*], yrange=[0,11], xrange=[0,2.5e-10], $ 80 | title = 'Falling History', $ 81 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 82 | oplot, [0,2.5e-10], [8,8], thick=1, lin=1 83 | xyouts, 1.5e-10, 8.2, 't = 0 sec' 84 | 85 | it = 100 86 | oplot, q[*,it], z[*], color=66, thick=3 87 | oplot, [0,2.5e-10], [6,6], color=66, thick=1, lin=1 88 | xyouts, 1.5e-10, 6.2, 't = 100000 sec' 89 | 90 | it = 200 91 | oplot, q[*,it], z[*], color=86, thick=3 92 | oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 93 | xyouts, 1.5e-10, 4.2, 't = 200000 sec' 94 | 95 | it = 300 96 | oplot, q[*,it], z[*], color=106, thick=3 97 | oplot, [0,2.5e-10], [2,2], color=106, thick=1, lin=1 98 | xyouts, 1.5e-10, 2.2, 't = 300000 sec' 99 | 100 | it = 400 101 | oplot, q[*,it], z[*], color=126, thick=3 102 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 103 | xyouts, 1.5e-10, 0.2, 't = 400000 sec' 104 | 105 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 106 | title = 'Total mass evolution' 107 | oplot, mass, thick=6, color=66, lin=0 108 | end 109 | -------------------------------------------------------------------------------- /tests/read_scfalltest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_scfalltest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz 5 | 6 | z = fltarr(nz) 7 | dz = fltarr(nz) 8 | 9 | data = fltarr(3) 10 | 11 | for iz = 0, nz-1 do begin 12 | readf, lun, data 13 | 14 | z[iz] = data[1] 15 | dz[iz] = data[2] 16 | endfor 17 | 18 | ; Read in the particles for each time step. 19 | mmr_ = fltarr(nz) 20 | q_ = fltarr(nz) 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | 26 | for iz = 0, nz-1 do begin 27 | readf, lun, data 28 | 29 | mmr_[iz] = data[1] 30 | q_[iz] = data[2] 31 | endfor 32 | 33 | if (nt eq 0) then begin 34 | time = t1 35 | mmr = mmr_ 36 | q = q_ 37 | endif else begin 38 | time = [time,t1] 39 | mmr = [mmr,mmr_] 40 | q = [q,q_] 41 | endelse 42 | 43 | nt = nt+1 44 | endwhile 45 | 46 | free_lun, lun 47 | 48 | mmr = reform(mmr,nz,nt) 49 | q = reform(q,nz,nt) 50 | 51 | z = z/1000. 52 | 53 | !p.multi = [0,1,2] 54 | loadct, 39 55 | 56 | ;Calculate the column mass, which should be conserved. 57 | mass = fltarr(nt) 58 | 59 | for it = 0, nt-1 do begin 60 | mass[it] = total(q[*,it]*dz[*]) 61 | endfor 62 | 63 | print 64 | 65 | for it = 0, nt-1 do begin 66 | plot, q[*,0], z[*], yrange=[0,11], xrange=[0,2.5e-10], $ 67 | title = 'time = '+string(time[it])+' seconds', $ 68 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 69 | oplot, q[*,it], z[*], lin=2, thick=3, color=66 70 | 71 | ; Show the mass evolution. 72 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 73 | title = 'Total mass evolution' 74 | oplot, mass[0:it], thick=6, color=66, lin=0 75 | 76 | wait, 0.01 77 | endfor 78 | 79 | plot, q[*,0], z[*], yrange=[0,11], xrange=[0,2.5e-10], $ 80 | title = 'Falling History', $ 81 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 82 | oplot, [0,2.5e-10], [8,8], thick=1, lin=1 83 | xyouts, 1.5e-10, 8.2, 't = 0 sec' 84 | 85 | it = 100 86 | oplot, q[*,it], z[*], color=66, thick=3 87 | oplot, [0,2.5e-10], [6,6], color=66, thick=1, lin=1 88 | xyouts, 1.5e-10, 6.2, 't = 100000 sec' 89 | 90 | it = 200 91 | oplot, q[*,it], z[*], color=86, thick=3 92 | oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 93 | xyouts, 1.5e-10, 4.2, 't = 200000 sec' 94 | 95 | it = 300 96 | oplot, q[*,it], z[*], color=106, thick=3 97 | oplot, [0,2.5e-10], [2,2], color=106, thick=1, lin=1 98 | xyouts, 1.5e-10, 2.2, 't = 300000 sec' 99 | 100 | it = 400 101 | oplot, q[*,it], z[*], color=126, thick=3 102 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 103 | xyouts, 1.5e-10, 0.2, 't = 400000 sec' 104 | 105 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 106 | title = 'Total mass evolution' 107 | oplot, mass, thick=6, color=66, lin=0 108 | end 109 | -------------------------------------------------------------------------------- /tests/read_vdiftest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_vdiftest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz 5 | 6 | z = fltarr(nz) 7 | dz = fltarr(nz) 8 | 9 | data = fltarr(3) 10 | 11 | for iz = 0, nz-1 do begin 12 | readf, lun, data 13 | 14 | z[iz] = data[1] 15 | dz[iz] = data[2] 16 | endfor 17 | 18 | ; Read in the particles for each time step. 19 | mmr_ = fltarr(nz) 20 | q_ = fltarr(nz) 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | 26 | for iz = 0, nz-1 do begin 27 | readf, lun, data 28 | 29 | mmr_[iz] = data[1] 30 | q_[iz] = data[2] 31 | endfor 32 | 33 | if (nt eq 0) then begin 34 | time = t1 35 | mmr = mmr_ 36 | q = q_ 37 | endif else begin 38 | time = [time,t1] 39 | mmr = [mmr,mmr_] 40 | q = [q,q_] 41 | endelse 42 | 43 | nt = nt+1 44 | endwhile 45 | 46 | free_lun, lun 47 | 48 | mmr = reform(mmr,nz,nt) 49 | q = reform(q,nz,nt) 50 | 51 | z = z/1000. 52 | 53 | !p.multi = [0,1,2] 54 | loadct, 39 55 | 56 | ;Calculate the column mass, which should be conserved. 57 | mass = fltarr(nt) 58 | 59 | for it = 0, nt-1 do begin 60 | mass[it] = total(q[*,it]*dz[*]) 61 | endfor 62 | 63 | print 64 | 65 | for it = 0, nt-1 do begin 66 | plot, q[*,0], z[*], yrange=[80,104], xrange=[0,2.5e-10], $ 67 | title = 'time = '+string(time[it])+' seconds', $ 68 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 69 | oplot, q[*,it], z[*], lin=2, thick=3, color=66 70 | 71 | ; Show the mass evolution. 72 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 73 | title = 'Total mass evolution' 74 | oplot, mass[0:it], thick=6, color=66, lin=0 75 | 76 | wait, 0.01 77 | endfor 78 | 79 | plot, q[*,0], z[*], yrange=[80,104], xrange=[0,2.5e-10], $ 80 | title = 'Falling History', $ 81 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 82 | oplot, [0,2.5e-10], [8,8], thick=1, lin=1 83 | xyouts, 1.5e-10, 8.2, 't = 0 sec' 84 | 85 | it = 100 86 | oplot, q[*,it], z[*], color=66, thick=3 87 | oplot, [0,2.5e-10], [6,6], color=66, thick=1, lin=1 88 | xyouts, 1.5e-10, 6.2, 't = 100000 sec' 89 | 90 | it = 200 91 | oplot, q[*,it], z[*], color=86, thick=3 92 | oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 93 | xyouts, 1.5e-10, 4.2, 't = 200000 sec' 94 | 95 | it = 300 96 | oplot, q[*,it], z[*], color=106, thick=3 97 | oplot, [0,2.5e-10], [2,2], color=106, thick=1, lin=1 98 | xyouts, 1.5e-10, 2.2, 't = 300000 sec' 99 | 100 | it = 400 101 | oplot, q[*,it], z[*], color=126, thick=3 102 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 103 | xyouts, 1.5e-10, 0.2, 't = 400000 sec' 104 | 105 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 106 | title = 'Total mass evolution' 107 | oplot, mass, thick=6, color=66, lin=0 108 | end 109 | -------------------------------------------------------------------------------- /tests/read_sigmafalltest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_sigmafalltest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz 5 | 6 | z = fltarr(nz) 7 | dz = fltarr(nz) 8 | 9 | data = fltarr(3) 10 | 11 | for iz = 0, nz-1 do begin 12 | readf, lun, data 13 | 14 | z[iz] = data[1] 15 | dz[iz] = data[2] 16 | endfor 17 | 18 | ; Read in the particles for each time step. 19 | mmr_ = fltarr(nz) 20 | q_ = fltarr(nz) 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | 26 | for iz = 0, nz-1 do begin 27 | readf, lun, data 28 | 29 | mmr_[iz] = data[1] 30 | q_[iz] = data[2] 31 | endfor 32 | 33 | if (nt eq 0) then begin 34 | time = t1 35 | mmr = mmr_ 36 | q = q_ 37 | endif else begin 38 | time = [time,t1] 39 | mmr = [mmr,mmr_] 40 | q = [q,q_] 41 | endelse 42 | 43 | nt = nt+1 44 | endwhile 45 | 46 | free_lun, lun 47 | 48 | mmr = reform(mmr,nz,nt) 49 | q = reform(q,nz,nt) 50 | 51 | z = z/1000. 52 | 53 | !p.multi = [0,1,2] 54 | loadct, 39 55 | 56 | ;Calculate the column mass, which should be conserved. 57 | mass = fltarr(nt) 58 | 59 | for it = 0, nt-1 do begin 60 | mass[it] = total(q[*,it]*dz[*]) 61 | endfor 62 | 63 | print 64 | 65 | for it = 0, nt-1 do begin 66 | plot, q[*,0], z[*], yrange=[0,11], xrange=[0,2.5e-10], $ 67 | title = 'time = '+string(time[it])+' seconds', $ 68 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 69 | oplot, q[*,it], z[*], lin=2, thick=3, color=66 70 | 71 | ; Show the mass evolution. 72 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 73 | title = 'Total mass evolution' 74 | oplot, mass[0:it], thick=6, color=66, lin=0 75 | 76 | wait, 0.01 77 | endfor 78 | 79 | plot, q[*,0], z[*], yrange=[0,11], xrange=[0,2.5e-10], $ 80 | title = 'Falling History', $ 81 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 82 | oplot, [0,2.5e-10], [8,8], thick=1, lin=1 83 | xyouts, 1.5e-10, 8.2, 't = 0 sec' 84 | 85 | it = 100 86 | oplot, q[*,it], z[*], color=66, thick=3 87 | oplot, [0,2.5e-10], [6,6], color=66, thick=1, lin=1 88 | xyouts, 1.5e-10, 6.2, 't = 100000 sec' 89 | 90 | it = 200 91 | oplot, q[*,it], z[*], color=86, thick=3 92 | oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 93 | xyouts, 1.5e-10, 4.2, 't = 200000 sec' 94 | 95 | it = 300 96 | oplot, q[*,it], z[*], color=106, thick=3 97 | oplot, [0,2.5e-10], [2,2], color=106, thick=1, lin=1 98 | xyouts, 1.5e-10, 2.2, 't = 300000 sec' 99 | 100 | it = 400 101 | oplot, q[*,it], z[*], color=126, thick=3 102 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 103 | xyouts, 1.5e-10, 0.2, 't = 400000 sec' 104 | 105 | plot, mass, xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 106 | title = 'Total mass evolution' 107 | oplot, mass, thick=6, color=66, lin=0 108 | end 109 | -------------------------------------------------------------------------------- /tests/read_mietest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_mietest.txt', /get_lun 2 | 3 | 4 | ; Read in the wavelengths. 5 | readf, lun, NGROUP, NWAVE, NBIN 6 | 7 | wave = fltarr(NWAVE) 8 | 9 | data = fltarr(2) 10 | 11 | for iwave = 0, NWAVE-1 do begin 12 | readf, lun, data 13 | 14 | wave[iwave] = data[1] 15 | endfor 16 | 17 | 18 | ; Read in the radius, refractive index and optical properties. 19 | r = fltarr(NBIN,NGROUP) 20 | refidx = fltarr(NWAVE,NGROUP) 21 | 22 | qext = fltarr(NWAVE,NGROUP,NBIN) 23 | ssa = fltarr(NWAVE,NGROUP,NBIN) 24 | asym = fltarr(NWAVE,NGROUP,NBIN) 25 | 26 | for igroup = 0, NGROUP-1 do begin 27 | data = fltarr(2) 28 | 29 | for ibin = 0, NBIN-1 do begin 30 | readf, lun, data 31 | r(ibin, igroup) = data[1] 32 | endfor 33 | 34 | data = fltarr(3) 35 | 36 | for iwave = 0, NWAVE-1 do begin 37 | readf, lun, data 38 | endfor 39 | 40 | data = fltarr(5) 41 | 42 | for iwave = 0, NWAVE-1 do begin 43 | for ibin = 0, NBIN-1 do begin 44 | readf, lun, data 45 | print, iwave, ibin, data 46 | 47 | qext(iwave, igroup, ibin) = data[2] 48 | ssa(iwave, igroup, ibin) = data[3] 49 | asym(iwave, igroup, ibin) = data[4] 50 | endfor 51 | endfor 52 | endfor 53 | 54 | free_lun, lun 55 | 56 | 57 | ; Plot qext, ssa and asym 58 | !p.multi=[0,1,3] 59 | loadct, 39 60 | 61 | for iwave = 0, NWAVE-1 do begin 62 | plot, r[*,0]*1e4, qext[iwave,0,*], yrange=[1e-5,5], xrange=[0.01,15], $ 63 | title = 'Extinction Efficiency, wavelength = '+string(wave[iwave]*1e4)+' (um)', $ 64 | xtitle='Radius [um]', ytitle = 'Qext', thick=3, /XLOG, /YLOG, charsize=2.0 65 | 66 | plot, r[*,0]*1e4, ssa[iwave,0,*], yrange=[0,1], xrange=[0.01,15], $ 67 | title = 'Single Scattering Albedo', $ 68 | xtitle='Radius [um]', ytitle = 'w', thick=3, /XLOG, charsize=2.0 69 | 70 | plot, r[*,0]*1e4, asym[iwave,0,*], yrange=[-1,1], xrange=[0.01,15], $ 71 | title = 'Asymmetry Factor', $ 72 | xtitle='Radius [um]', ytitle = 'g', thick=3, /XLOG, charsize=2.0 73 | 74 | wait, .1 75 | endfor 76 | 77 | plot, r[*,0]*1e4, qext[0,0,*], yrange=[1e-5,5], xrange=[0.01,15], $ 78 | title = 'Extinction Efficiency, wavelength = '+string(wave[0]*1e4)+' to '+string(wave[NWAVE-1]*1e4)+' (um)', $ 79 | xtitle='Radius [um]', ytitle = 'Qext', thick=2, /XLOG, /YLOG, charsize=2.0 80 | for iwave = 0, NWAVE-1 do begin 81 | oplot, r[*,0]*1e4, qext[iwave,0,*], thick=2, color=30+4*iwave 82 | endfor 83 | 84 | plot, r[*,0]*1e4, ssa[0,0,*], yrange=[0,1], xrange=[0.01,15], $ 85 | title = 'Single Scattering Albedo', $ 86 | xtitle='Radius [um]', ytitle = 'w', thick=2, /XLOG, charsize=2.0 87 | for iwave = 0, NWAVE-1 do begin 88 | oplot, r[*,0]*1e4, ssa[iwave,0,*], thick=2, color=30+4*iwave 89 | endfor 90 | 91 | plot, r[*,0]*1e4, asym[0,0,*], yrange=[-1,1], xrange=[0.01,15], $ 92 | title = 'Asymmetry Factor', $ 93 | xtitle='Radius [um]', ytitle = 'g', thick=2, /XLOG, charsize=2.0 94 | for iwave = 0, NWAVE-1 do begin 95 | oplot, r[*,0]*1e4, asym[iwave,0,*], thick=2, color=30+4*iwave 96 | endfor 97 | end 98 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Test utilities 3 | 4 | include(test_util) 5 | 6 | ################################################################################ 7 | # Tests 8 | 9 | create_standard_test(NAME version SOURCES atmosphere_mod.F90 carma_versiontest.F90) 10 | create_standard_test(NAME bc2g SOURCES atmosphere_mod.F90 carma_bc2gtest.F90) 11 | create_standard_test(NAME bcoc SOURCES atmosphere_mod.F90 carma_bcoctest.F90) 12 | create_standard_test(NAME ce SOURCES atmosphere_mod.F90 carma_cetest.F90) 13 | create_standard_test(NAME coag SOURCES atmosphere_mod.F90 carma_coagtest.F90) 14 | create_standard_test(NAME drydep SOURCES atmosphere_mod.F90 carma_drydeptest.F90) 15 | create_standard_test(NAME fall SOURCES atmosphere_mod.F90 carma_falltest.F90) 16 | create_standard_test(NAME fractalmicro SOURCES atmosphere_mod.F90 carma_fractalmicrotest.F90) 17 | create_standard_test(NAME fractaloptics SOURCES atmosphere_mod.F90 carma_fractalopticstest.F90) 18 | create_standard_test(NAME growclr SOURCES atmosphere_mod.F90 carma_growclrtest.F90) 19 | create_standard_test(NAME growin SOURCES atmosphere_mod.F90 carma_growintest.F90) 20 | create_standard_test(NAME growsub SOURCES atmosphere_mod.F90 carma_growsubtest.F90) 21 | create_standard_test(NAME grow SOURCES atmosphere_mod.F90 carma_growtest.F90) 22 | create_standard_test(NAME init SOURCES atmosphere_mod.F90 carma_inittest.F90) 23 | create_standard_test(NAME kappawetr SOURCES atmosphere_mod.F90 carma_kappawetrtest.F90) 24 | create_standard_test(NAME mie SOURCES atmosphere_mod.F90 carma_mietest.F90) 25 | create_standard_test(NAME nuc2 SOURCES atmosphere_mod.F90 carma_nuc2test.F90) 26 | create_standard_test(NAME nuc SOURCES atmosphere_mod.F90 carma_nuctest.F90) 27 | create_standard_test(NAME pheat SOURCES atmosphere_mod.F90 carma_pheattest.F90) 28 | create_standard_test(NAME scfall SOURCES atmosphere_mod.F90 carma_scfalltest.F90) 29 | create_standard_test(NAME sigmadrydep SOURCES atmosphere_mod.F90 carma_sigmadrydeptest.F90) 30 | create_standard_test(NAME sigmafall SOURCES atmosphere_mod.F90 carma_sigmafalltest.F90) 31 | create_standard_test(NAME sulfate_ccdon SOURCES atmosphere_mod.F90 carma_sulfate_ccdon_test.F90) 32 | create_standard_test(NAME sulfate_vehkamaki SOURCES atmosphere_mod.F90 carma_sulfate_vehkamaki_test.F90) 33 | create_standard_test(NAME sulfate SOURCES atmosphere_mod.F90 carma_sulfatetest.F90) 34 | create_standard_test(NAME sulfhet_vehkamaki SOURCES atmosphere_mod.F90 carma_sulfhet_vehkamaki_test.F90) 35 | create_standard_test(NAME sulfhet SOURCES atmosphere_mod.F90 carma_sulfhettest.F90) 36 | create_standard_test(NAME swell SOURCES atmosphere_mod.F90 carma_swelltest.F90) 37 | create_standard_test(NAME vdif SOURCES atmosphere_mod.F90 carma_vdiftest.F90) 38 | 39 | if(CARMA_ENABLE_NETCDF) 40 | create_standard_test(NAME aluminum_netcdf SOURCES atmosphere_mod.F90 test2nc_mod.F90 nc_types_mod.F90 ncio_mod.F90 carmadiags_mod.F90 carma_aluminum_2nc_test.F90) 41 | create_standard_test(NAME fractal_optics_netcdf SOURCES atmosphere_mod.F90 test2nc_mod.F90 nc_types_mod.F90 ncio_mod.F90 carmadiags_mod.F90 carma_fractaloptics_2nc_test.F90) 42 | create_standard_test(NAME sulfate_netcdf SOURCES atmosphere_mod.F90 test2nc_mod.F90 nc_types_mod.F90 ncio_mod.F90 carmadiags_mod.F90 carma_sulfate_2nc_test.F90) 43 | endif() 44 | 45 | ################################################################################ -------------------------------------------------------------------------------- /run-carma.csh: -------------------------------------------------------------------------------- 1 | #! /bin/tcsh -f 2 | # An entry point for running the CARMA code, which creates a run directory 3 | # copies in the executable and the then runs the executable. 4 | # 5 | # NOTE: This script could be easily enhanced to manage mutliple executables and 6 | # multiple run directories, which my be useful as part of an automated test 7 | # suite. 8 | # 9 | # Usage 10 | # run-carma.csh [test] 11 | # 12 | # test - the name of an executable test case 13 | # 14 | 15 | # Environment Variables 16 | # CARMA_BUILD [carma] 17 | # The subdirectory in which the build was performed. 18 | 19 | # By default, run the single column model 20 | if (! $?CARMA_BUILD ) then 21 | setenv CARMA_BUILD carma 22 | endif 23 | 24 | if (! $?CARMA_CASE ) then 25 | setenv CARMA_CASE $CARMA_BUILD 26 | endif 27 | 28 | if (! $?CARMA_THREADS ) then 29 | setenv CARMA_THREADS 1 30 | endif 31 | 32 | if (! $?CARMA_IDL ) then 33 | setenv CARMA_IDL idl 34 | endif 35 | 36 | set runtgt=CARMATEST.exe 37 | 38 | if ($# == 1) then 39 | set runtgt="$1" 40 | endif 41 | 42 | set blddir=build/$CARMA_BUILD 43 | set rundir=run/$CARMA_CASE 44 | set testdir=tests 45 | set idlfile="read_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.pro" 46 | set outfile="carma_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.txt" 47 | 48 | echo $idlfile 49 | echo $outfile 50 | 51 | # Create a directory for the build. 52 | echo "Running $blddir/$runtgt in the directory $rundir using $CARMA_THREADS thread(s) ..." 53 | mkdir -p $rundir 54 | 55 | # Copy the executable to the run directory. 56 | cp $blddir/$runtgt $rundir 57 | 58 | if (-f $testdir/$idlfile) then 59 | 60 | # Don't overwrite the file in the run directory if it is newer than 61 | # the one in the test directory. 62 | # 63 | # NOTE: For the test on modification date to work, the copy must 64 | # preserve the modify date and time. 65 | if (-f $rundir/$idlfile) then 66 | if (-M "$rundir/$idlfile" > -M "$testdir/$idlfile") then 67 | setenv IDL_WARNING " WARNING: $idlfile not copied, since $rundir/$idlfile is newer than $testdir/$idlfile" 68 | else 69 | cp -p $testdir/$idlfile $rundir 70 | endif 71 | else 72 | cp -p $testdir/$idlfile $rundir 73 | endif 74 | endif 75 | 76 | # Prepare for multiple threads, assuming Intel Compiler. 77 | setenv OMP_NUM_THREADS $CARMA_THREADS 78 | setenv KMP_STACKSIZE 128M 79 | 80 | # Execute the make file in the build directory. 81 | cd $rundir 82 | echo " ** Started at `date` **" 83 | ./$runtgt || echo ' *** Run Failed ***' && exit -1 84 | echo " ** Finished at `date` **" 85 | 86 | if (-f $idlfile) then 87 | 88 | if (-f $outfile) then 89 | echo "" 90 | echo "Running the IDL analysis routine $idlfile" 91 | 92 | if ($?IDL_WARNING) then 93 | echo "" 94 | echo "$IDL_WARNING" 95 | echo "" 96 | endif 97 | 98 | echo " To run the test, in IDL you need to type the command: .r $idlfile" 99 | echo " To exit IDL, type the command: exit" 100 | 101 | # NOTE: If your invokation of IDL fails, check to see whether idl 102 | # is really on you path or if it is just an alias. Aliases don't work 103 | # properly in scripts, but this is how IDL is setup be default. You 104 | # can add the idl bin directory to your path so that this will work. 105 | echo "" 106 | $CARMA_IDL 107 | endif 108 | endif 109 | 110 | 111 | -------------------------------------------------------------------------------- /tests/bench/carma_cetest.txt: -------------------------------------------------------------------------------- 1 | 2 3 16 0 2 | 1 1 0.100E-02 0.746E-20 3 | 1 2 0.159E-02 0.298E-19 4 | 1 3 0.252E-02 0.119E-18 5 | 1 4 0.400E-02 0.477E-18 6 | 1 5 0.635E-02 0.191E-17 7 | 1 6 0.101E-01 0.763E-17 8 | 1 7 0.160E-01 0.305E-16 9 | 1 8 0.254E-01 0.122E-15 10 | 1 9 0.403E-01 0.489E-15 11 | 1 10 0.640E-01 0.195E-14 12 | 1 11 0.102E+00 0.782E-14 13 | 1 12 0.161E+00 0.313E-13 14 | 1 13 0.256E+00 0.125E-12 15 | 1 14 0.406E+00 0.500E-12 16 | 1 15 0.645E+00 0.200E-11 17 | 1 16 0.102E+01 0.801E-11 18 | 2 1 0.500E+00 0.487E-12 19 | 2 2 0.794E+00 0.195E-11 20 | 2 3 0.126E+01 0.779E-11 21 | 2 4 0.200E+01 0.312E-10 22 | 2 5 0.317E+01 0.125E-09 23 | 2 6 0.504E+01 0.499E-09 24 | 2 7 0.800E+01 0.199E-08 25 | 2 8 0.127E+02 0.798E-08 26 | 2 9 0.202E+02 0.319E-07 27 | 2 10 0.320E+02 0.128E-06 28 | 2 11 0.508E+02 0.511E-06 29 | 2 12 0.806E+02 0.204E-05 30 | 2 13 0.128E+03 0.817E-05 31 | 2 14 0.203E+03 0.327E-04 32 | 2 15 0.323E+03 0.131E-03 33 | 2 16 0.512E+03 0.523E-03 34 | 0 35 | 1 1 0.376E-28 36 | 1 2 0.668E-24 37 | 1 3 0.324E-20 38 | 1 4 0.428E-17 39 | 1 5 0.154E-14 40 | 1 6 0.152E-12 41 | 1 7 0.407E-11 42 | 1 8 0.298E-10 43 | 1 9 0.596E-10 44 | 1 10 0.325E-10 45 | 1 11 0.484E-11 46 | 1 12 0.196E-12 47 | 1 13 0.218E-14 48 | 1 14 0.657E-17 49 | 1 15 0.542E-20 50 | 1 16 0.122E-23 51 | 2 1 0.752E-29 52 | 2 2 0.134E-24 53 | 2 3 0.647E-21 54 | 2 4 0.855E-18 55 | 2 5 0.308E-15 56 | 2 6 0.303E-13 57 | 2 7 0.815E-12 58 | 2 8 0.597E-11 59 | 2 9 0.119E-10 60 | 2 10 0.650E-11 61 | 2 11 0.968E-12 62 | 2 12 0.393E-13 63 | 2 13 0.435E-15 64 | 2 14 0.131E-17 65 | 2 15 0.108E-20 66 | 2 16 0.244E-24 67 | 3 1 0.376E-29 68 | 3 2 0.668E-25 69 | 3 3 0.324E-21 70 | 3 4 0.428E-18 71 | 3 5 0.154E-15 72 | 3 6 0.152E-13 73 | 3 7 0.407E-12 74 | 3 8 0.298E-11 75 | 3 9 0.596E-11 76 | 3 10 0.325E-11 77 | 3 11 0.484E-12 78 | 3 12 0.196E-13 79 | 3 13 0.218E-15 80 | 3 14 0.657E-18 81 | 3 15 0.542E-21 82 | 3 16 0.122E-24 83 | 1. 84 | 1 1 0.376E-28 85 | 1 2 0.668E-24 86 | 1 3 0.324E-20 87 | 1 4 0.428E-17 88 | 1 5 0.154E-14 89 | 1 6 0.152E-12 90 | 1 7 0.407E-11 91 | 1 8 0.298E-10 92 | 1 9 0.596E-10 93 | 1 10 0.325E-10 94 | 1 11 0.484E-11 95 | 1 12 0.196E-12 96 | 1 13 0.218E-14 97 | 1 14 0.657E-17 98 | 1 15 0.542E-20 99 | 1 16 0.122E-23 100 | 2 1 0.752E-29 101 | 2 2 0.134E-24 102 | 2 3 0.647E-21 103 | 2 4 0.855E-18 104 | 2 5 0.308E-15 105 | 2 6 0.303E-13 106 | 2 7 0.815E-12 107 | 2 8 0.597E-11 108 | 2 9 0.119E-10 109 | 2 10 0.650E-11 110 | 2 11 0.968E-12 111 | 2 12 0.393E-13 112 | 2 13 0.435E-15 113 | 2 14 0.131E-17 114 | 2 15 0.108E-20 115 | 2 16 0.244E-24 116 | 3 1 0.376E-29 117 | 3 2 0.668E-25 118 | 3 3 0.324E-21 119 | 3 4 0.428E-18 120 | 3 5 0.154E-15 121 | 3 6 0.152E-13 122 | 3 7 0.407E-12 123 | 3 8 0.298E-11 124 | 3 9 0.596E-11 125 | 3 10 0.325E-11 126 | 3 11 0.484E-12 127 | 3 12 0.196E-13 128 | 3 13 0.218E-15 129 | 3 14 0.657E-18 130 | 3 15 0.542E-21 131 | 3 16 0.122E-24 132 | -------------------------------------------------------------------------------- /run-regress.csh: -------------------------------------------------------------------------------- 1 | #! /bin/tcsh -f 2 | # An entry point for running all of the carma regression tests. It creates 3 | # a run directory, copies in the executables, runs all of the test executables, 4 | # and then compares the results to the previous "benchmark" result. 5 | # 6 | # The benchmark results are run on a Mac using ifort 7 | # 8 | # 9 | # Usage 10 | # run-carma.csh 11 | 12 | # Environment Variables 13 | # CARMA_BUILD [carma] 14 | # The subdirectory in which the build was performed. 15 | 16 | # By default, run the single column model 17 | if (! $?CARMA_BUILD ) then 18 | setenv CARMA_BUILD carma 19 | endif 20 | 21 | if (! $?CARMA_CASE ) then 22 | setenv CARMA_CASE $CARMA_BUILD 23 | endif 24 | 25 | if (! $?CARMA_THREADS ) then 26 | setenv CARMA_THREADS 1 27 | endif 28 | 29 | if (! $?CARMA_IDL ) then 30 | setenv CARMA_IDL idl 31 | endif 32 | 33 | set runtgt=CARMATEST.exe 34 | 35 | if ($# == 1) then 36 | set runtgt="$1" 37 | endif 38 | 39 | set blddir=build/$CARMA_BUILD 40 | set rundir=run/$CARMA_CASE 41 | set testdir=tests 42 | set benchdir=tests/bench 43 | 44 | # Initialize string to capture user y/n response 45 | set doall="" 46 | 47 | # Initialize index to count number of pairs of differing files to 0 48 | set ndiffs=0 49 | 50 | # Clear the screen and advance two lines 51 | clear 52 | echo "" 53 | echo "" 54 | 55 | # Inquire if the user wants to to have the script stop on the first instance of 56 | # a difference found between a test file and its corresponding benchmark file 57 | # 58 | echo " Do you want the script to stop on the first difference found between " 59 | echo -n " a test file and its corresponding benchmark file? (y/n) " 60 | set doall = $< 61 | 62 | # Create a directory for the build. 63 | mkdir -p $rundir 64 | 65 | # Copy the executable to the run directory. 66 | cp $blddir/*TEST.exe $rundir 67 | 68 | # Prepare for multiple threads, assuming Intel Compiler. 69 | setenv OMP_NUM_THREADS $CARMA_THREADS 70 | setenv OMP_STACKSIZE 128M 71 | 72 | # Execute the tests. 73 | cd $rundir 74 | 75 | foreach runtgt (`ls -1 *TEST.exe`) 76 | echo "" 77 | echo "" 78 | echo " ** Starting $runtgt at `date` **" 79 | #Run the test program; if the test fails exit the script 80 | ./$runtgt || echo ' *** Run Failed ***' && exit -1 81 | echo " ** Finished at `date` **" 82 | echo "" 83 | 84 | set outfile="carma_`echo $runtgt:r | tr '[A-Z]' '[a-z]'`.txt" 85 | 86 | setenv FDIFF -sqw 87 | 88 | # The diff on AIX doesn't have the -q option ..." 89 | if (`uname` == AIX ) then 90 | setenv FDIFF -sw 91 | endif 92 | 93 | # check for exisitence of output file and set up the diff-grep string 94 | if (-f $outfile) then 95 | set grepdiff=`diff $FDIFF $outfile ../../$benchdir/$outfile | grep -o differ` 96 | 97 | # if a difference is found between the test file and its benchmark file... 98 | if $grepdiff != "" then 99 | # ... then print out a message to that effect 100 | echo " " $outfile "differs from benchmark file ../../"$benchdir/$outfile " " 101 | echo "" 102 | #if the user wants the script to stop on the first difference, then do so... 103 | if ( $doall == "y" || $doall == "Y" ) then 104 | echo " Quitting." 105 | echo "" 106 | exit -1 107 | else 108 | # otherwise, increment the number of differing file pairs found 109 | set ndiffs = `expr $ndiffs + 1` 110 | endif 111 | endif 112 | endif 113 | endif 114 | end 115 | 116 | echo "" 117 | echo " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" 118 | echo "" 119 | # How many differences were found between test and benchmark files? 120 | echo " There are " $ndiffs "test files that differ from their corresponding benchmark files." 121 | echo "" 122 | echo "" 123 | -------------------------------------------------------------------------------- /tests/bench/carma_growintest.txt: -------------------------------------------------------------------------------- 1 | 1 1 18 1 2 | 1 1 0.100E+01 0.390E-11 3 | 1 2 0.126E+01 0.779E-11 4 | 1 3 0.159E+01 0.156E-10 5 | 1 4 0.200E+01 0.312E-10 6 | 1 5 0.252E+01 0.623E-10 7 | 1 6 0.317E+01 0.125E-09 8 | 1 7 0.400E+01 0.249E-09 9 | 1 8 0.504E+01 0.499E-09 10 | 1 9 0.635E+01 0.997E-09 11 | 1 10 0.800E+01 0.199E-08 12 | 1 11 0.101E+02 0.399E-08 13 | 1 12 0.127E+02 0.798E-08 14 | 1 13 0.160E+02 0.160E-07 15 | 1 14 0.202E+02 0.319E-07 16 | 1 15 0.254E+02 0.638E-07 17 | 1 16 0.320E+02 0.128E-06 18 | 1 17 0.403E+02 0.255E-06 19 | 1 18 0.508E+02 0.511E-06 20 | 0 21 | 0 0 0.000E+00 22 | 1 1 0.236E-08 23 | 1 2 0.000E+00 24 | 1 3 0.000E+00 25 | 1 4 0.000E+00 26 | 1 5 0.000E+00 27 | 1 6 0.000E+00 28 | 1 7 0.000E+00 29 | 1 8 0.000E+00 30 | 1 9 0.000E+00 31 | 1 10 0.000E+00 32 | 1 11 0.000E+00 33 | 1 12 0.000E+00 34 | 1 13 0.000E+00 35 | 1 14 0.000E+00 36 | 1 15 0.000E+00 37 | 1 16 0.000E+00 38 | 1 17 0.000E+00 39 | 1 18 0.000E+00 40 | 1 0.350E-05 0.000E+00 0.000E+00 41 | 1000. 42 | 32 0 0.15430E-02 43 | 1 1 0.000E+00 44 | 1 2 0.878E-19 45 | 1 3 0.196E-16 46 | 1 4 0.364E-14 47 | 1 5 0.529E-12 48 | 1 6 0.691E-10 49 | 1 7 0.787E-08 50 | 1 8 0.101E-06 51 | 1 9 0.298E-06 52 | 1 10 0.140E-06 53 | 1 11 0.101E-07 54 | 1 12 0.437E-09 55 | 1 13 0.117E-10 56 | 1 14 0.193E-12 57 | 1 15 0.198E-14 58 | 1 16 0.129E-16 59 | 1 17 0.538E-19 60 | 1 18 0.579E-21 61 | 1 0.294E-05 0.769E+00 0.142E+01 62 | 2000. 63 | 8 1 0.27308E-02 64 | 1 1 0.000E+00 65 | 1 2 0.153E-22 66 | 1 3 0.144E-19 67 | 1 4 0.975E-17 68 | 1 5 0.410E-14 69 | 1 6 0.128E-11 70 | 1 7 0.330E-09 71 | 1 8 0.262E-07 72 | 1 9 0.233E-06 73 | 1 10 0.552E-06 74 | 1 11 0.162E-06 75 | 1 12 0.110E-07 76 | 1 13 0.455E-09 77 | 1 14 0.111E-10 78 | 1 15 0.161E-12 79 | 1 16 0.139E-14 80 | 1 17 0.739E-17 81 | 1 18 0.946E-19 82 | 1 0.252E-05 0.672E+00 0.122E+01 83 | 3000. 84 | 8 3 0.33927E-02 85 | 1 1 0.000E+00 86 | 1 2 0.548E-25 87 | 1 3 0.114E-21 88 | 1 4 0.180E-18 89 | 1 5 0.150E-15 90 | 1 6 0.894E-13 91 | 1 7 0.433E-10 92 | 1 8 0.903E-08 93 | 1 9 0.177E-06 94 | 1 10 0.616E-06 95 | 1 11 0.388E-06 96 | 1 12 0.314E-07 97 | 1 13 0.141E-08 98 | 1 14 0.372E-10 99 | 1 15 0.583E-12 100 | 1 16 0.550E-14 101 | 1 17 0.315E-16 102 | 1 18 0.432E-18 103 | 1 0.228E-05 0.618E+00 0.112E+01 104 | 4000. 105 | 4 2 0.37558E-02 106 | 1 1 0.000E+00 107 | 1 2 0.429E-26 108 | 1 3 0.124E-22 109 | 1 4 0.296E-19 110 | 1 5 0.348E-16 111 | 1 6 0.263E-13 112 | 1 7 0.165E-10 113 | 1 8 0.468E-08 114 | 1 9 0.149E-06 115 | 1 10 0.610E-06 116 | 1 11 0.537E-06 117 | 1 12 0.496E-07 118 | 1 13 0.242E-08 119 | 1 14 0.674E-10 120 | 1 15 0.111E-11 121 | 1 16 0.109E-13 122 | 1 17 0.651E-16 123 | 1 18 0.931E-18 124 | 1 0.215E-05 0.588E+00 0.106E+01 125 | 5000. 126 | 2 1 0.39363E-02 127 | 1 1 0.215E-27 128 | 1 2 0.346E-24 129 | 1 3 0.465E-21 130 | 1 4 0.310E-18 131 | 1 5 0.147E-15 132 | 1 6 0.666E-13 133 | 1 7 0.210E-10 134 | 1 8 0.530E-08 135 | 1 9 0.135E-06 136 | 1 10 0.591E-06 137 | 1 11 0.620E-06 138 | 1 12 0.637E-07 139 | 1 13 0.334E-08 140 | 1 14 0.980E-10 141 | 1 15 0.168E-11 142 | 1 16 0.171E-13 143 | 1 17 0.106E-15 144 | 1 18 0.136E-17 145 | 1 0.208E-05 0.573E+00 0.103E+01 146 | -------------------------------------------------------------------------------- /tests/bench/carma_growsubtest.txt: -------------------------------------------------------------------------------- 1 | 1 1 18 1 2 | 1 1 0.100E+01 0.390E-11 3 | 1 2 0.126E+01 0.779E-11 4 | 1 3 0.159E+01 0.156E-10 5 | 1 4 0.200E+01 0.312E-10 6 | 1 5 0.252E+01 0.623E-10 7 | 1 6 0.317E+01 0.125E-09 8 | 1 7 0.400E+01 0.249E-09 9 | 1 8 0.504E+01 0.499E-09 10 | 1 9 0.635E+01 0.997E-09 11 | 1 10 0.800E+01 0.199E-08 12 | 1 11 0.101E+02 0.399E-08 13 | 1 12 0.127E+02 0.798E-08 14 | 1 13 0.160E+02 0.160E-07 15 | 1 14 0.202E+02 0.319E-07 16 | 1 15 0.254E+02 0.638E-07 17 | 1 16 0.320E+02 0.128E-06 18 | 1 17 0.403E+02 0.255E-06 19 | 1 18 0.508E+02 0.511E-06 20 | 0 21 | 0 0 0.000E+00 22 | 1 1 0.236E-08 23 | 1 2 0.000E+00 24 | 1 3 0.000E+00 25 | 1 4 0.000E+00 26 | 1 5 0.000E+00 27 | 1 6 0.000E+00 28 | 1 7 0.000E+00 29 | 1 8 0.000E+00 30 | 1 9 0.000E+00 31 | 1 10 0.000E+00 32 | 1 11 0.000E+00 33 | 1 12 0.000E+00 34 | 1 13 0.000E+00 35 | 1 14 0.000E+00 36 | 1 15 0.000E+00 37 | 1 16 0.000E+00 38 | 1 17 0.000E+00 39 | 1 18 0.000E+00 40 | 1 0.350E-05 0.000E+00 0.000E+00 41 | 1000. 42 | 32 0 0.15767E-02 43 | 1 1 0.323E-23 44 | 1 2 0.317E-19 45 | 1 3 0.176E-16 46 | 1 4 0.237E-14 47 | 1 5 0.310E-12 48 | 1 6 0.489E-10 49 | 1 7 0.681E-08 50 | 1 8 0.978E-07 51 | 1 9 0.303E-06 52 | 1 10 0.150E-06 53 | 1 11 0.109E-07 54 | 1 12 0.452E-09 55 | 1 13 0.110E-10 56 | 1 14 0.160E-12 57 | 1 15 0.139E-14 58 | 1 16 0.725E-17 59 | 1 17 0.229E-19 60 | 1 18 0.172E-21 61 | 1 0.293E-05 0.666E+00 0.131E+01 62 | 2000. 63 | 4 1 0.29253E-02 64 | 1 1 0.860E-27 65 | 1 2 0.284E-22 66 | 1 3 0.519E-19 67 | 1 4 0.221E-16 68 | 1 5 0.792E-14 69 | 1 6 0.249E-11 70 | 1 7 0.581E-09 71 | 1 8 0.236E-07 72 | 1 9 0.211E-06 73 | 1 10 0.568E-06 74 | 1 11 0.230E-06 75 | 1 12 0.208E-07 76 | 1 13 0.110E-08 77 | 1 14 0.339E-10 78 | 1 15 0.623E-12 79 | 1 16 0.695E-14 80 | 1 17 0.476E-16 81 | 1 18 0.795E-18 82 | 1 0.245E-05 0.556E+00 0.109E+01 83 | 3000. 84 | 2 1 0.34161E-02 85 | 1 1 0.358E-28 86 | 1 2 0.200E-23 87 | 1 3 0.607E-20 88 | 1 4 0.374E-17 89 | 1 5 0.183E-14 90 | 1 6 0.747E-12 91 | 1 7 0.205E-09 92 | 1 8 0.128E-07 93 | 1 9 0.172E-06 94 | 1 10 0.599E-06 95 | 1 11 0.404E-06 96 | 1 12 0.409E-07 97 | 1 13 0.231E-08 98 | 1 14 0.757E-10 99 | 1 15 0.147E-11 100 | 1 16 0.174E-13 101 | 1 17 0.125E-15 102 | 1 18 0.218E-17 103 | 1 0.227E-05 0.516E+00 0.101E+01 104 | 4000. 105 | 1 0 0.35263E-02 106 | 1 1 0.136E-28 107 | 1 2 0.918E-24 108 | 1 3 0.306E-20 109 | 1 4 0.198E-17 110 | 1 5 0.105E-14 111 | 1 6 0.478E-12 112 | 1 7 0.146E-09 113 | 1 8 0.108E-07 114 | 1 9 0.164E-06 115 | 1 10 0.601E-06 116 | 1 11 0.446E-06 117 | 1 12 0.461E-07 118 | 1 13 0.264E-08 119 | 1 14 0.876E-10 120 | 1 15 0.172E-11 121 | 1 16 0.204E-13 122 | 1 17 0.148E-15 123 | 1 18 0.260E-17 124 | 1 0.223E-05 0.507E+00 0.997E+00 125 | 5000. 126 | 1 0 0.35043E-02 127 | 1 1 0.633E-25 128 | 1 2 0.504E-22 129 | 1 3 0.202E-19 130 | 1 4 0.727E-17 131 | 1 5 0.253E-14 132 | 1 6 0.775E-12 133 | 1 7 0.172E-09 134 | 1 8 0.119E-07 135 | 1 9 0.165E-06 136 | 1 10 0.598E-06 137 | 1 11 0.439E-06 138 | 1 12 0.457E-07 139 | 1 13 0.262E-08 140 | 1 14 0.872E-10 141 | 1 15 0.172E-11 142 | 1 16 0.204E-13 143 | 1 17 0.148E-15 144 | 1 18 0.250E-17 145 | 1 0.224E-05 0.509E+00 0.100E+01 146 | -------------------------------------------------------------------------------- /tests/read_drydeptest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_drydeptest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz, nelem 5 | z = fltarr(nz) 6 | dz = fltarr(nz) 7 | 8 | data = fltarr(3) 9 | 10 | for iz = 0, nz-1 do begin 11 | readf, lun, data 12 | 13 | z[iz] = data[1] 14 | dz[iz] = data[2] 15 | endfor 16 | 17 | ; Read in the particles for each time step. 18 | mmr_ = fltarr(nz, nelem) 19 | q_ = fltarr(nz, nelem) 20 | 21 | data = fltarr(4) 22 | 23 | nt = 0 24 | while(not(eof(lun))) do begin 25 | readf, lun, t1 26 | 27 | for ielem = 0, nelem-1 do begin 28 | for iz = 0, nz-1 do begin 29 | readf, lun, data 30 | 31 | mmr_[iz, ielem] = data[2] 32 | q_[iz, ielem] = data[3] 33 | endfor 34 | endfor 35 | 36 | if (nt eq 0) then begin 37 | time = t1 38 | mmr = mmr_ 39 | q = q_ 40 | endif else begin 41 | time = [time,t1] 42 | mmr = [mmr,mmr_] 43 | q = [q,q_] 44 | endelse 45 | 46 | nt = nt+1 47 | endwhile 48 | 49 | free_lun, lun 50 | 51 | mmr = reform(mmr,nz,nt,nelem) 52 | q = reform(q,nz,nt,nelem) 53 | 54 | z = z/1000. 55 | 56 | !p.multi = [0,1,2] 57 | loadct, 39 58 | 59 | ;Calculate the column mass, which should be conserved. 60 | mass = fltarr(nelem,nt) 61 | 62 | for ielem = 0, nelem-1 do begin 63 | for it = 0, nt-1 do begin 64 | mass[ielem,it] = total(q[*,it,ielem]*dz[*]) 65 | endfor 66 | endfor 67 | 68 | 69 | for it = 0, nt-1 do begin 70 | plot, q[*,0,0], z[*], yrange=[1.e-2,15], xrange=[1.e-15,2.e-10], $ 71 | title = 'time = '+string(time[it])+' seconds', $ 72 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3, $ 73 | /xlog, /ylog 74 | 75 | ; Add a legend 76 | plots, [1.5e-10,2.5e-10], 0.1, thick=3, color=66, lin=0 77 | plots, [1.5e-10,2.5e-10], 0.2, thick=3, color=66, lin=1 78 | xyouts, 3.0e-10, 0.1, 'DryDep', color=66 79 | xyouts, 3.0e-10, 0.2, 'NoDryDep', color=66 80 | 81 | for ielem = 0, nelem-1 do begin 82 | oplot, q[*,it,ielem], z[*], lin=ielem, thick=3, color=66 83 | endfor 84 | 85 | ; Show the mass evolution. 86 | plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 87 | title = 'Total mass evolution' 88 | for ielem = 0, nelem-1 do begin 89 | oplot, mass[ielem,*], thick=6, lin=ielem 90 | endfor 91 | for ielem = 0, nelem-1 do begin 92 | oplot, mass[ielem,0:it], thick=6, color=66, lin=ielem 93 | endfor 94 | 95 | wait, 0.01 96 | endfor 97 | 98 | plot, q[*,0,0], z[*], yrange=[1.e-2,15], xrange=[1.e-15,2.e-10], $ 99 | title = 'Falling History', $ 100 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3, $ 101 | /xlog,/ylog 102 | oplot, [1.e-15,1.e-9], [8,8], thick=1, lin=1 103 | xyouts, 2.5e-10, 2.0, 't = 0 sec' 104 | 105 | ; Add a legend 106 | plots, [1.5e-10,2.5e-10], 0.1, thick=3, lin=0 107 | plots, [1.5e-10,2.5e-10], 0.2, thick=3, lin=1 108 | xyouts, 3.e-10, 0.1, 'DryDep' 109 | xyouts, 3.e-10, 0.2, 'NoDryDep' 110 | 111 | 112 | it = 200 113 | for ielem = 0, nelem-1 do begin 114 | oplot, q[*,it,ielem], z[*], color=86, thick=3, line=ielem 115 | endfor 116 | ;oplot, [1.e-2,2.5e-10], [4,4], color=86, thick=1, lin=1 117 | xyouts, 2.5e-10, 1.0, 't = 200000 sec', color=86 118 | 119 | it = 400 120 | for ielem = 0, nelem-1 do begin 121 | oplot, q[*,it,ielem], z[*], color=126, thick=3, line=ielem 122 | endfor 123 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 124 | xyouts, 2.5e-10, 0.5, 't = 400000 sec', color=126 125 | 126 | plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 127 | title = 'Total mass evolution' 128 | for ielem = 0, nelem-1 do begin 129 | oplot, mass[ielem,*], thick=6, color=66, lin=ielem 130 | endfor 131 | end 132 | -------------------------------------------------------------------------------- /tests/read_sigmadrydeptest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_sigmadrydeptest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz, nelem 5 | z = fltarr(nz) 6 | dz = fltarr(nz) 7 | 8 | data = fltarr(3) 9 | 10 | for iz = 0, nz-1 do begin 11 | readf, lun, data 12 | 13 | z[iz] = data[1] 14 | dz[iz] = data[2] 15 | endfor 16 | 17 | ; Read in the particles for each time step. 18 | mmr_ = fltarr(nz, nelem) 19 | q_ = fltarr(nz, nelem) 20 | 21 | data = fltarr(4) 22 | 23 | nt = 0 24 | while(not(eof(lun))) do begin 25 | readf, lun, t1 26 | 27 | for ielem = 0, nelem-1 do begin 28 | for iz = 0, nz-1 do begin 29 | readf, lun, data 30 | 31 | mmr_[iz, ielem] = data[2] 32 | q_[iz, ielem] = data[3] 33 | endfor 34 | endfor 35 | 36 | if (nt eq 0) then begin 37 | time = t1 38 | mmr = mmr_ 39 | q = q_ 40 | endif else begin 41 | time = [time,t1] 42 | mmr = [mmr,mmr_] 43 | q = [q,q_] 44 | endelse 45 | 46 | nt = nt+1 47 | endwhile 48 | 49 | free_lun, lun 50 | 51 | mmr = reform(mmr,nz,nt,nelem) 52 | q = reform(q,nz,nt,nelem) 53 | 54 | z = z/1000. 55 | 56 | !p.multi = [0,1,2] 57 | loadct, 39 58 | 59 | ;Calculate the column mass, which should be conserved. 60 | mass = fltarr(nelem,nt) 61 | 62 | for ielem = 0, nelem-1 do begin 63 | for it = 0, nt-1 do begin 64 | mass[ielem,it] = total(q[*,it,ielem]*dz[*]) 65 | endfor 66 | endfor 67 | 68 | 69 | for it = 0, nt-1 do begin 70 | plot, q[*,0,0], z[*], yrange=[1.e-2,15], xrange=[1.e-15,2.e-10], $ 71 | title = 'time = '+string(time[it])+' seconds', $ 72 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3, $ 73 | /xlog, /ylog 74 | 75 | ; Add a legend 76 | plots, [1.5e-10,2.5e-10], 0.1, thick=3, color=66, lin=0 77 | plots, [1.5e-10,2.5e-10], 0.2, thick=3, color=66, lin=1 78 | xyouts, 3.0e-10, 0.1, 'DryDep', color=66 79 | xyouts, 3.0e-10, 0.2, 'NoDryDep', color=66 80 | 81 | for ielem = 0, nelem-1 do begin 82 | oplot, q[*,it,ielem], z[*], lin=ielem, thick=3, color=66 83 | endfor 84 | 85 | ; Show the mass evolution. 86 | plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 87 | title = 'Total mass evolution' 88 | for ielem = 0, nelem-1 do begin 89 | oplot, mass[ielem,*], thick=6, lin=ielem 90 | endfor 91 | for ielem = 0, nelem-1 do begin 92 | oplot, mass[ielem,0:it], thick=6, color=66, lin=ielem 93 | endfor 94 | 95 | wait, 0.01 96 | endfor 97 | 98 | plot, q[*,0,0], z[*], yrange=[1.e-2,15], xrange=[1.e-15,2.e-10], $ 99 | title = 'Falling History', $ 100 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3, $ 101 | /xlog,/ylog 102 | oplot, [1.e-15,1.e-9], [8,8], thick=1, lin=1 103 | xyouts, 2.5e-10, 2.0, 't = 0 sec' 104 | 105 | ; Add a legend 106 | plots, [1.5e-10,2.5e-10], 0.1, thick=3, lin=0 107 | plots, [1.5e-10,2.5e-10], 0.2, thick=3, lin=1 108 | xyouts, 3.e-10, 0.1, 'DryDep' 109 | xyouts, 3.e-10, 0.2, 'NoDryDep' 110 | 111 | 112 | it = 200 113 | for ielem = 0, nelem-1 do begin 114 | oplot, q[*,it,ielem], z[*], color=86, thick=3, line=ielem 115 | endfor 116 | ;oplot, [1.e-2,2.5e-10], [4,4], color=86, thick=1, lin=1 117 | xyouts, 2.5e-10, 1.0, 't = 200000 sec', color=86 118 | 119 | it = 400 120 | for ielem = 0, nelem-1 do begin 121 | oplot, q[*,it,ielem], z[*], color=126, thick=3, line=ielem 122 | endfor 123 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 124 | xyouts, 2.5e-10, 0.5, 't = 400000 sec', color=126 125 | 126 | plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 127 | title = 'Total mass evolution' 128 | for ielem = 0, nelem-1 do begin 129 | oplot, mass[ielem,*], thick=6, color=66, lin=ielem 130 | endfor 131 | end 132 | -------------------------------------------------------------------------------- /tests/read_swelltest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_swelltest.txt', /get_lun 2 | 3 | ; Read in the vertical grid. 4 | readf, lun, nz, nelem 5 | z = fltarr(nz) 6 | dz = fltarr(nz) 7 | 8 | data = fltarr(3) 9 | 10 | for iz = 0, nz-1 do begin 11 | readf, lun, data 12 | 13 | z[iz] = data[1] 14 | dz[iz] = data[2] 15 | endfor 16 | 17 | ; Read in the particles for each time step. 18 | mmr_ = fltarr(nz, nelem) 19 | q_ = fltarr(nz, nelem) 20 | 21 | data = fltarr(4) 22 | 23 | nt = 0 24 | while(not(eof(lun))) do begin 25 | readf, lun, t1 26 | 27 | for ielem = 0, nelem-1 do begin 28 | for iz = 0, nz-1 do begin 29 | readf, lun, data 30 | 31 | mmr_[iz, ielem] = data[2] 32 | q_[iz, ielem] = data[3] 33 | endfor 34 | endfor 35 | 36 | if (nt eq 0) then begin 37 | time = t1 38 | mmr = mmr_ 39 | q = q_ 40 | endif else begin 41 | time = [time,t1] 42 | mmr = [mmr,mmr_] 43 | q = [q,q_] 44 | endelse 45 | 46 | nt = nt+1 47 | endwhile 48 | 49 | free_lun, lun 50 | 51 | mmr = reform(mmr,nz,nt,nelem) 52 | q = reform(q,nz,nt,nelem) 53 | 54 | z = z/1000. 55 | 56 | !p.multi = [0,1,2] 57 | loadct, 39 58 | 59 | ;Calculate the column mass, which should be conserved. 60 | mass = fltarr(nelem,nt) 61 | 62 | for ielem = 0, nelem-1 do begin 63 | for it = 0, nt-1 do begin 64 | mass[ielem,it] = total(q[*,it,ielem]*dz[*]) 65 | endfor 66 | endfor 67 | 68 | 69 | for it = 0, nt-1 do begin 70 | plot, q[*,0,0], z[*], yrange=[0,15], xrange=[0,2.e-10], $ 71 | title = 'time = '+string(time[it])+' seconds', $ 72 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 73 | 74 | ; Add a legend 75 | plots, [1.5e-10,1.75e-10], 4.2, thick=3, color=66, lin=0 76 | plots, [1.5e-10,1.75e-10], 2.7, thick=3, color=66, lin=1 77 | plots, [1.5e-10,1.75e-10], 1.2, thick=3, color=66, lin=2 78 | xyouts, 1.8e-10, 4.2, 'None', color=66 79 | xyouts, 1.8e-10, 2.7, 'Fitzgerald', color=66 80 | xyouts, 1.8e-10, 1.2, 'Gerber', color=66 81 | 82 | for ielem = 0, nelem-1 do begin 83 | oplot, q[*,it,ielem], z[*], lin=ielem, thick=3, color=66 84 | endfor 85 | 86 | ; Show the mass evolution. 87 | plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 88 | title = 'Total mass evolution' 89 | for ielem = 0, nelem-1 do begin 90 | oplot, mass[ielem,*], thick=6, lin=ielem 91 | endfor 92 | for ielem = 0, nelem-1 do begin 93 | oplot, mass[ielem,0:it], thick=6, color=66, lin=ielem 94 | endfor 95 | 96 | wait, 0.01 97 | endfor 98 | 99 | plot, q[*,0,0], z[*], yrange=[0,15], xrange=[0,2.e-10], $ 100 | title = 'Falling History', $ 101 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 102 | oplot, [0,2.5e-10], [8,8], thick=1, lin=1 103 | xyouts, 1.5e-10, 9.2, 't = 0 sec' 104 | 105 | ; Add a legend 106 | plots, [1.5e-10,1.75e-10], 4.2, thick=3, lin=0 107 | plots, [1.5e-10,1.75e-10], 2.7, thick=3, lin=1 108 | plots, [1.5e-10,1.75e-10], 1.2, thick=3, lin=2 109 | xyouts, 1.8e-10, 4.2, 'None' 110 | xyouts, 1.8e-10, 2.7, 'Fitzgerald' 111 | xyouts, 1.8e-10, 1.2, 'Gerber' 112 | 113 | it = 200 114 | for ielem = 0, nelem-1 do begin 115 | oplot, q[*,it,ielem], z[*], color=86, thick=3, line=ielem 116 | endfor 117 | oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 118 | xyouts, 1.5e-10, 7.7, 't = 200000 sec', color=86 119 | 120 | it = 400 121 | for ielem = 0, nelem-1 do begin 122 | oplot, q[*,it,ielem], z[*], color=126, thick=3, line=ielem 123 | endfor 124 | oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 125 | xyouts, 1.5e-10, 6.2, 't = 400000 sec', color=126 126 | 127 | plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 128 | title = 'Total mass evolution' 129 | for ielem = 0, nelem-1 do begin 130 | oplot, mass[ielem,*], thick=6, color=66, lin=ielem 131 | endfor 132 | end 133 | -------------------------------------------------------------------------------- /source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CARMA source 3 | 4 | # object library 5 | add_library(carma_object OBJECT) 6 | 7 | set_target_properties(carma_object PROPERTIES 8 | Fortran_MODULE_DIRECTORY ${CARMA_MOD_DIR} 9 | ) 10 | 11 | target_include_directories( 12 | carma_object 13 | PUBLIC 14 | $ 15 | $ 16 | $ 17 | $ 18 | ) 19 | 20 | target_link_libraries( 21 | carma_object 22 | PRIVATE 23 | ${LAPACK_LIBRARIES} 24 | LAPACK::LAPACK 25 | ${BLAS_LIBRARIES} 26 | ) 27 | if(CARMA_ENABLE_NETCDF) 28 | target_link_libraries( 29 | carma_object 30 | PUBLIC 31 | PkgConfig::netcdff 32 | PkgConfig::netcdfc 33 | ) 34 | endif() 35 | 36 | add_library(carma $) 37 | add_library(musica::carma ALIAS carma) 38 | 39 | if(NOT BUILD_SHARED_LIBS) 40 | set_target_properties(carma_object PROPERTIES POSITION_INDEPENDENT_CODE ON) 41 | endif() 42 | 43 | set_target_properties( 44 | carma 45 | PROPERTIES 46 | ARCHIVE_OUTPUT_DIRECTORY ${CARMA_LIB_DIR} 47 | VERSION ${PROJECT_VERSION} 48 | SOVERSION ${PROJECT_VERSION_MAJOR} 49 | ) 50 | 51 | target_link_libraries(carma PUBLIC carma_object) 52 | 53 | message( 54 | STATUS 55 | "CARMA build include directories: ${CARMA_MOD_DIR};${CMAKE_CURRENT_SOURCE_DIR}/base" 56 | ) 57 | message( 58 | STATUS 59 | "CARMA install include directories: ${CARMA_INSTALL_MOD_DIR};${CMAKE_INSTALL_INCLUDEDIR}" 60 | ) 61 | target_include_directories( 62 | carma 63 | PUBLIC 64 | $ 65 | $ 66 | $ 67 | $ 68 | ) 69 | 70 | configure_file(version.F90.in ${CMAKE_CURRENT_BINARY_DIR}/version.F90 @ONLY) 71 | 72 | target_sources( 73 | carma_object 74 | PRIVATE 75 | base/actdropl.F90 76 | base/adgaquad_mod.F90 77 | base/adgaquad_types_mod.F90 78 | base/bhmie.F90 79 | base/calcrs.F90 80 | base/carma_constants_mod.F90 81 | base/carma_enums_mod.F90 82 | base/carma_mod.F90 83 | base/carma_precision_mod.F90 84 | base/carma_types_mod.F90 85 | base/carmaelement_mod.F90 86 | base/carmagas_mod.F90 87 | base/carmagroup_mod.F90 88 | base/carmasolute_mod.F90 89 | base/carmastate_mod.F90 90 | base/coagl.F90 91 | base/coagp.F90 92 | base/coremasscheck.F90 93 | base/csolve.F90 94 | base/detrain.F90 95 | base/downgevapply.F90 96 | base/downgxfer.F90 97 | base/evap_ingrp.F90 98 | base/evap_mono.F90 99 | base/evap_poly.F90 100 | base/evapp.F90 101 | base/fixcorecol.F90 102 | base/fractal_meanfield_mod.F90 103 | base/freezaerl_koop2000.F90 104 | base/freezaerl_mohler2010.F90 105 | base/freezaerl_tabazadeh2000.F90 106 | base/freezdropl.F90 107 | base/freezglaerl_murray2010.F90 108 | base/gasexchange.F90 109 | base/growevapl.F90 110 | base/growp.F90 111 | base/gsolve.F90 112 | base/hetnucl.F90 113 | base/hygroscopicity.F90 114 | base/maxconc.F90 115 | base/melticel.F90 116 | base/microfast.F90 117 | base/microslow.F90 118 | base/mie.F90 119 | base/miess.F90 120 | base/newstate.F90 121 | base/newstate_calc.F90 122 | base/nsubsteps.F90 123 | base/pheat.F90 124 | base/planck.F90 125 | base/prestep.F90 126 | base/psolve.F90 127 | base/rhoice_heymsfield2010.F90 128 | base/rhopart.F90 129 | base/setupatm.F90 130 | base/setupbdif.F90 131 | base/setupbins.F90 132 | base/setupckern.F90 133 | base/setupcoag.F90 134 | base/setupgkern.F90 135 | base/setupgrow.F90 136 | base/setupnuc.F90 137 | base/setupvdry.F90 138 | base/setupvf.F90 139 | base/setupvf_heymsfield2010.F90 140 | base/setupvf_std.F90 141 | base/setupvf_std_shape.F90 142 | base/smallconc.F90 143 | base/step.F90 144 | base/sulfate_utils.F90 145 | base/sulfhetnucrate.F90 146 | base/sulfnuc.F90 147 | base/sulfnucrate.F90 148 | base/supersat.F90 149 | base/totalcondensate.F90 150 | base/tsolve.F90 151 | base/upgxfer.F90 152 | base/vaporp.F90 153 | base/vaporp_h2o_buck1981.F90 154 | base/vaporp_h2o_goff1946.F90 155 | base/vaporp_h2o_murphy2005.F90 156 | base/vaporp_h2so4_ayers1980.F90 157 | base/versol.F90 158 | base/versub.F90 159 | base/vertadv.F90 160 | base/vertdif.F90 161 | base/vertical.F90 162 | base/wetr.F90 163 | base/zeromicro.F90 164 | ${CMAKE_CURRENT_BINARY_DIR}/version.F90 165 | ../tests/atmosphere_mod.F90 166 | ) -------------------------------------------------------------------------------- /tests/read_bcoctest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_bcoctest.txt', /get_lun 2 | readf, lun, nbin, nelem, ngroup 3 | 4 | ; ibin_ = intarr(nbin) 5 | r = fltarr(nbin,ngroup) ; radius (cm) 6 | dr = fltarr(nbin,ngroup) ; delta radius (cm) 7 | data = fltarr(3) 8 | 9 | for igroup = 0, ngroup-1 do begin 10 | for ibin = 0, nbin-1 do begin 11 | readf, lun, data 12 | ; ibin_[ibin] = fix( data[0] ) 13 | r[ibin,igroup] = data[1] 14 | dr[ibin,igroup] = data[2] 15 | endfor 16 | endfor 17 | 18 | data2 = fltarr(2) 19 | pc_ = fltarr(nbin,nelem) ; mass (g/cm^-3) in a bin 20 | 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | 26 | for ielem = 0, nelem-1 do begin 27 | for ibin = 0, nbin-1 do begin 28 | readf, lun, data2 29 | ; ibin_[ibin] = fix( data2[0] ) 30 | pc_[ibin,ielem] = data2[1] 31 | endfor 32 | endfor 33 | 34 | ; ibin = [ibin,ibin_] 35 | if (t1 eq 0.) then begin 36 | pc = pc_ 37 | time = t1 38 | endif else begin 39 | pc = [pc,pc_] 40 | time = [time,t1] 41 | endelse 42 | 43 | nt = nt+1 44 | endwhile 45 | 46 | free_lun, lun 47 | 48 | pc = reform(pc,nbin,nt,nelem) 49 | 50 | 51 | 52 | ; Map units for this test 53 | ; 4 elements: 1 - BC, 2 - OC, 3 - OC shell, 4 - BC core 54 | ; Elements 1 - 3 are PC; element 4 is COREMASS 55 | ; For now, all elements have same size and mass dimensions 56 | d = 2.*r*1e4 57 | dd = 2.*dr*1e4 58 | 59 | dnlogd = alog(10.) * pc 60 | for ibin = 0, nbin-1 do begin 61 | dnlogd[ibin,*,0] = dnlogd[ibin,*,0]*d[ibin,0]/dd[ibin,0] 62 | dnlogd[ibin,*,1] = dnlogd[ibin,*,1]*d[ibin,1]/dd[ibin,1] 63 | dnlogd[ibin,*,2] = dnlogd[ibin,*,2]*d[ibin,2]/dd[ibin,2] 64 | dnlogd[ibin,*,3] = dnlogd[ibin,*,3]*d[ibin,2]/dd[ibin,2] 65 | endfor 66 | 67 | ; BCOC 68 | mass = total(pc[*,*,0],1) + total(pc[*,*,1],1) + total(pc[*,*,2],1) 69 | massbc = total(pc[*,*,0],1) + total(pc[*,*,3],1) 70 | massoc = total(pc[*,*,1],1) + total(pc[*,*,2],1) - total(pc[*,*,3],1) 71 | massmix = total(pc[*,*,2],1) 72 | massmbc = total(pc[*,*,3],1) 73 | massmoc = total(pc[*,*,2],1) - total(pc[*,*,3],1) 74 | 75 | 76 | ; Plot 77 | !p.font=0 78 | !p.multi = [0,1,2] 79 | loadct, 39 80 | 81 | ; Can't display 0 in log coordinates 82 | dnlogd[where(dnlogd le 0.)] = !Values.F_NAN 83 | 84 | for it = 0, nt-1 do begin 85 | plot, d[*,0], dnlogd[*,0,0], $ 86 | /xlog, /ylog, /nodata, xtitle = 'Diameter [um]', ytitle = 'dM/dlogD [g/cm3]', $ 87 | xrange=[.005,.3], yrange=[1.e-21,1.e-11], xstyle=1 88 | 89 | oplot, d[*,0], dnlogd[*,0,0], color=254, psym=2 90 | oplot, d[*,1], dnlogd[*,0,1], color=176, psym=4 91 | 92 | oplot, d[*,0], dnlogd[*,it,0], thick=6, color=254, lin=0 93 | oplot, d[*,1], dnlogd[*,it,1], thick=3, color=176, lin=2 94 | oplot, d[*,2], dnlogd[*,it,2], thick=3, color=84, lin=0 95 | oplot, d[*,2], dnlogd[*,it,3], thick=3, color=84, lin=2 96 | 97 | xyouts, .15, 1.e-12, 'BC (pure group)', color=254 98 | xyouts, .15, 1.e-13, 'OC (pure group)', color=176 99 | xyouts, .15, 1.e-14, 'OC+BC (mixed group)', color=84 100 | xyouts, .15, 1.e-15, 'BC (core of mixed group)', color=84 101 | plots, [.1,.13], 1.5e-12, thick=6, color=254 102 | plots, [.1,.13], 1.5e-13, thick=3, color=176, lin=2 103 | plots, [.1,.13], 1.5e-14, thick=3, color=84 104 | plots, [.1,.13], 1.5e-15, thick=3, color=84, lin=2 105 | 106 | 107 | ; Show the mass evolution. 108 | plot, mass, xtitle = 'Time Step', ytitle = 'Total Mass Density [g/cm3]' 109 | oplot, mass[0:it], thick=3, color=66, lin=0 110 | oplot, massoc[0:it], thick=9, color=84, lin=0 111 | oplot, massbc[0:it], thick=3, color=176, lin=0 112 | oplot, massmix[0:it], thick=3, color=66, lin=2 113 | oplot, massmbc[0:it], thick=6, color=176, lin=2 114 | oplot, massmoc[0:it], thick=3, color=84, lin=2 115 | 116 | plots, [50,55], 2.0e-13, thick=3, color=66 117 | plots, [50,55], 1.8e-13, thick=3, color=66, lin=2 118 | xyouts, 57, 1.95e-13, 'Total Mass', color=66 119 | xyouts, 57, 1.75e-13, 'Mixed Group Mass', color=66 120 | 121 | plots, [50,55], 0.9e-13, thick=3, color=176 122 | plots, [50,55], 0.7e-13, thick=9, color=84 123 | plots, [50,55], 0.5e-13, thick=6, color=176, lin=2 124 | plots, [50,55], 0.3e-13, thick=3, color=84, lin=2 125 | xyouts, 57, 0.85e-13, 'Total BC', color=176 126 | xyouts, 57, 0.65e-13, 'Total OC', color=84 127 | xyouts, 57, 0.45e-13, 'Mixed BC', color=176 128 | xyouts, 57, 0.25e-13, 'Mixed OC', color=84 129 | 130 | 131 | wait, .05 132 | endfor 133 | 134 | end 135 | -------------------------------------------------------------------------------- /bin/f90doc-0.4.0/f90doc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | eval 'exec perl $0 ${1+"$@"}' 3 | if 0; 4 | warn ("Perl 5 not detected, likely a big problem") if $] < 5.0; 5 | warn "Less than Perl 5.003. You may witness mysterious segmentation faults." 6 | if $] < 5.003; 7 | 8 | use strict; 9 | 10 | BEGIN { 11 | my $zero = $0; 12 | while (-l $zero) { 13 | my $nextzero = readlink $zero; 14 | if (substr ($nextzero, 0, 1) eq "/") { 15 | $zero = $nextzero; 16 | } elsif ($zero =~ m#^(.*)/#) { 17 | $zero = "$1/$nextzero"; 18 | } else { 19 | $zero = $nextzero; 20 | } 21 | } 22 | if ($zero =~ m#(.*)/\w+#) { 23 | push @INC, "$1/../common/", $1; 24 | } else { 25 | push @INC, "../common/", "."; 26 | } 27 | } 28 | 29 | require "htmling.pl"; 30 | require "stmts.pl"; 31 | require "utils.pl"; 32 | #require "expr_parse.pl"; 33 | #require "typing.pl"; 34 | 35 | #################### 36 | 37 | if (! @ARGV) { 38 | print <$part in module $1"); 149 | } else { 150 | push (@::see_list, "module $1"); 151 | } 152 | } elsif ($macro =~ /^author\s+/i) { 153 | push (@::authors, $'); 154 | } elsif ($macro =~ /^version\s+/i) { 155 | die "Two versions in a single !! block" if $::version_num; 156 | $::version_num = $'; 157 | } else { 158 | die "Unrecognized macro $macro"; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /tests/carma_inittest.F90: -------------------------------------------------------------------------------- 1 | !! This code is to test the error handling in the CARMA configuration and 2 | !! initialization interface. 3 | !! 4 | !! @author Chuck Bardeen 5 | !! @version Mar-2009 6 | 7 | program carma_inittest 8 | implicit none 9 | 10 | write(*,*) "CARMA Initializtion Test" 11 | 12 | call test_initialization() 13 | 14 | write(*,*) "Done" 15 | end program 16 | 17 | 18 | subroutine test_initialization() 19 | use carma_precision_mod 20 | use carma_constants_mod 21 | use carma_enums_mod 22 | use carma_types_mod 23 | use carmaelement_mod 24 | use carmagroup_mod 25 | use carma_mod 26 | 27 | implicit none 28 | 29 | integer, parameter :: NX = 1 30 | integer, parameter :: NY = 1 31 | integer, parameter :: NZ = 80 32 | integer, parameter :: NZP1 = NZ+1 33 | integer, parameter :: NELEM = 3 34 | integer, parameter :: NBIN = 20 35 | integer, parameter :: NGROUP = 2 36 | integer, parameter :: NSOLUTE = 0 37 | integer, parameter :: NGAS = 0 38 | integer, parameter :: NWAVE = 0 39 | integer, parameter :: nstep = 72 40 | 41 | real(kind=f), parameter :: dtime = 600._f 42 | real(kind=f), parameter :: deltax = 100._f 43 | real(kind=f), parameter :: deltay = 100._f 44 | real(kind=f), parameter :: deltaz = 100._f 45 | real(kind=f), parameter :: zmin = 0._f 46 | 47 | integer, parameter :: I_BLACKCARBON = 1 48 | integer, parameter :: I_ORGANICCARBON = 2 49 | 50 | type(carma_type), target :: carma 51 | type(carma_type), pointer :: carma_ptr 52 | integer :: rc = 0 53 | 54 | real(kind=f), allocatable :: xc(:,:,:) 55 | real(kind=f), allocatable :: dx(:,:,:) 56 | real(kind=f), allocatable :: yc(:,:,:) 57 | real(kind=f), allocatable :: dy(:,:,:) 58 | real(kind=f), allocatable :: zc(:,:,:) 59 | real(kind=f), allocatable :: zl(:,:,:) 60 | real(kind=f), allocatable :: p(:,:,:) 61 | real(kind=f), allocatable :: pl(:,:,:) 62 | real(kind=f), allocatable :: t(:,:,:) 63 | real(kind=f), allocatable :: rhoa(:,:,:) 64 | 65 | real(kind=f), allocatable, target :: mmr(:,:,:,:,:) 66 | 67 | real(kind=f), allocatable :: lat(:,:) 68 | real(kind=f), allocatable :: lon(:,:) 69 | 70 | integer :: i, j 71 | integer :: ix 72 | integer :: iy 73 | integer :: ixy 74 | integer :: istep 75 | integer :: ielem 76 | integer :: ibin 77 | integer :: ithread 78 | integer, parameter :: lun = 42 79 | 80 | real(kind=f) :: time 81 | real(kind=f) :: rmin, rmrat, ck0 82 | real(kind=f) :: r(NBIN) 83 | real(kind=f) :: dr(NBIN) 84 | real(kind=f) :: rmass(NBIN) 85 | 86 | 87 | ! write(*,*) "" 88 | 89 | ! Define the particle-grid extent of the CARMA test 90 | call CARMA_Create(carma, NBIN, NELEM, NGROUP, NSOLUTE, NGAS, NWAVE, rc, LUNOPRT=6) 91 | if (rc /=0) stop " *** FAILED ***" 92 | carma_ptr => carma 93 | 94 | ! Define the groups 95 | ! ----------------- 96 | ! write(*,*) " Add Group(s) ..." 97 | rmrat = 2._f 98 | rmin = 3.e-7_f 99 | call CARMAGROUP_Create(carma, 1, 'mixed carbon', rmin, rmrat, I_SPHERE, 1._f, .FALSE., rc) 100 | if (rc /=0) stop " *** FAILED ***" 101 | 102 | call CARMAGROUP_Create(carma, 2, 'organic carbon', rmin, rmrat, I_SPHERE, 1._f, .FALSE., rc) 103 | if (rc /=0) stop " *** FAILED ***" 104 | 105 | 106 | ! Define the elements 107 | ! ------------------- 108 | ! write(*,*) " Add Element(s) ..." 109 | 110 | ! Organic Carbon 111 | call CARMAELEMENT_Create(carma, 1, 1, "bc in mixed", 1._f, I_INVOLATILE, I_BLACKCARBON, rc) 112 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 113 | 114 | call CARMAELEMENT_Create(carma, 2, 1, "oc in mixed", 1._f, I_COREMASS, I_ORGANICCARBON, rc) 115 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 116 | 117 | call CARMAELEMENT_Create(carma, 3, 2, "organic carbon", 1._f, I_INVOLATILE, I_ORGANICCARBON, rc) 118 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 119 | 120 | 121 | ! AddCoagulation Tests ... 122 | write(*,*) "" 123 | write(*,*) " Check for group too large in AddCoagulation ... Should Fail" 124 | write(*,*) "" 125 | call CARMA_AddCoagulation(carma, 4, 1, 1, I_COLLEC_DATA, rc) 126 | if (rc /=0) then 127 | rc = 0 128 | else 129 | stop " *** FAILED ***" 130 | endif 131 | call CARMA_AddCoagulation(carma, 1, 4, 1, I_COLLEC_DATA, rc) 132 | if (rc /=0) then 133 | rc = 0 134 | else 135 | stop " *** FAILED ***" 136 | endif 137 | call CARMA_AddCoagulation(carma, 1, 1, 4, I_COLLEC_DATA, rc) 138 | if (rc /=0) then 139 | rc = 0 140 | else 141 | stop " *** FAILED ***" 142 | endif 143 | 144 | ! Initialization Tests 145 | write(*,*) "" 146 | write(*,*) " Check for order of element list ... Should Fail" 147 | write(*,*) "" 148 | call CARMA_AddCoagulation(carma, 1, 1, 1, I_COLLEC_DATA, rc) 149 | call CARMA_AddCoagulation(carma, 2, 2, 2, I_COLLEC_DATA, rc) 150 | call CARMA_AddCoagulation(carma, 2, 1, 1, I_COLLEC_DATA, rc) 151 | if (rc /=0) stop " *** FAILED ***" 152 | 153 | call CARMA_Initialize(carma, rc, do_coag=.TRUE.) 154 | if (rc /=0) then 155 | rc = 0 156 | else 157 | stop " *** FAILED ***" 158 | endif 159 | 160 | 161 | write(*,*) "" 162 | ! write(*,*) " CARMA_Destroy() ..." 163 | call CARMA_Destroy(carma, rc) 164 | if (rc /=0) write(*, *) " *** FAILED ***, rc=", rc 165 | end subroutine 166 | -------------------------------------------------------------------------------- /tests/read_fractalmicrotest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_fractalmicrotest.txt', /get_lun 2 | 3 | ; Read in bin structure 4 | readf,lun, nbin, rmon 5 | 6 | df = fltarr(nbin) 7 | r = fltarr(nbin) 8 | rrat = fltarr(nbin) 9 | rprat = fltarr(nbin) 10 | nmon = fltarr(nbin) 11 | 12 | data= fltarr(6) 13 | for ib = 0, nbin-1 do begin 14 | readf, lun, data 15 | df[ib] = data[1] 16 | r[ib] = data[2] 17 | rrat[ib] = data[3] 18 | rprat[ib] = data[4] 19 | nmon[ib] = data[5] 20 | endfor 21 | 22 | ; Write bin parameters out 23 | ;print, "ib, df, r_sphere, rrat, rprat" 24 | ;for ib = 0, nbin-1 do begin 25 | ; print, ib, df(ib), r(ib), rrat(ib), rprat(ib) 26 | ;endfor 27 | 28 | 29 | ; Read in the vertical grid. 30 | readf, lun, nz 31 | 32 | z = fltarr(nz) 33 | dz = fltarr(nz) 34 | 35 | data = fltarr(3) 36 | 37 | for iz = 0, nz-1 do begin 38 | readf, lun, data 39 | 40 | z[iz] = data[1] 41 | dz[iz] = data[2] 42 | endfor 43 | 44 | ; Read in the particles for each time step. 45 | pc_f_ = fltarr(nz) ; particle concentration #/cm-3 46 | q_f_ = fltarr(nz) ; mass concentration g/cm-3 47 | pc_s_ = fltarr(nz) ; particle concentration #/cm-3 48 | q_s_ = fltarr(nz) ; mass concentration g/cm-3 49 | data2 = fltarr(5) 50 | 51 | nt = 0 52 | while(not(eof(lun))) do begin 53 | readf, lun, t1 54 | for iz = 0, nz-1 do begin 55 | ;for ib = 0, nbin-1 do begin 56 | readf, lun, data2 57 | pc_f_[iz] = data2[1] 58 | q_f_[iz] = data2[2] 59 | pc_s_[iz] = data2[3] 60 | q_s_[iz] = data2[4] 61 | ;endfor 62 | endfor 63 | 64 | if (nt eq 0) then begin 65 | time = t1 66 | pc_f = pc_f_ 67 | q_f = q_f_ 68 | pc_s = pc_s_ 69 | q_s = q_s_ 70 | endif else begin 71 | time = [time,t1] 72 | pc_f = [pc_f,pc_f_] 73 | q_f = [q_f,q_f_] 74 | pc_s = [pc_s,pc_s_] 75 | q_s = [q_s,q_s_] 76 | endelse 77 | nt = nt+1 78 | endwhile 79 | 80 | free_lun, lun 81 | 82 | 83 | pc_f = reform(pc_f,nz,nt) 84 | q_f = reform(q_f,nz,nt) 85 | pc_s = reform(pc_s,nz,nt) 86 | q_s = reform(q_s,nz,nt) 87 | z = z/1000. 88 | 89 | ;Calculate the column mass, which should be conserved. 90 | zmass_f = fltarr(nz,nt) 91 | pctot_f = fltarr(nz,nt) 92 | zmass_s = fltarr(nz,nt) 93 | pctot_s = fltarr(nz,nt) 94 | 95 | for it = 0, nt-1 do begin 96 | for iz = 0, nz-1 do begin 97 | zmass_f[iz,it] = total(q_f[iz,it]) 98 | pctot_f[iz,it] = total(pc_f[iz,it]) 99 | zmass_s[iz,it] = total(q_s[iz,it]) 100 | pctot_s[iz,it] = total(pc_s[iz,it]) 101 | endfor 102 | endfor 103 | 104 | 105 | 106 | ;plotting to do 107 | ;plot effective r,rf,rm versus altitude 108 | ; try to duplicate plot RE_RB_RF 109 | 110 | r_eff_f = fltarr(nz,nt) 111 | r_eff_s = fltarr(nz,nt) 112 | rf_eff_f = fltarr(nz,nt) 113 | rm_eff_f = fltarr(nz,nt) 114 | 115 | ; for it=0,nt-1 do begin 116 | ; for iz=0,nz-1 do begin 117 | ; rtemp3_f = 0. & rftemp3_f = 0. & rmtemp3_f = 0. 118 | ; rtemp2_f = 0. & rftemp2_f = 0. & rmtemp2_f = 0. 119 | ; rtemp3_s = 0. 120 | ; rtemp2_s = 0. 121 | ; for ib=0,nbin-1 do begin 122 | ; rtemp3_f = rtemp3_f + 4.0/3.0*!pi*r(ib)^3.*pc_f(iz,it,ib) * 1.0e12 123 | ; rtemp2_f = rtemp2_f + 4.0*!pi*r(ib)^2.*pc_f(iz,it,ib) * 1.0e8 124 | ; 125 | ; rftemp3_f = rftemp3_f + 4.0/3.0*!pi*(r(ib)*rrat(ib))^3.*pc_f(iz,it,ib) * 1.0e12 126 | ; rftemp2_f = rftemp2_f + 4.0*!pi*(r(ib)*rrat(ib))^2.*pc_f(iz,it,ib) * 1.0e8 127 | ; 128 | ; rmtemp3_f = rmtemp3_f + 4.0/3.0*!pi*(r(ib)*rprat(ib))^3.*pc_f(iz,it,ib) * 1.0e12 129 | ; rmtemp2_f = rmtemp2_f + 4.0*!pi*(r(ib)*rprat(ib))^2.*pc_f(iz,it,ib) * 1.0e8 130 | ; 131 | ; rtemp3_s = rtemp3_s + 4.0/3.0*!pi*r(ib)^3.*pc_s(iz,it,ib) * 1.0e12 132 | ; rtemp2_s = rtemp2_s + 4.0*!pi*r(ib)^2.*pc_s(iz,it,ib) * 1.0e8 133 | ; 134 | ; endfor 135 | ; 136 | ; r_eff_f(iz,it) = 3.0*rtemp3_f/rtemp2_f 137 | ; rf_eff_f(iz,it) = 3.0*rftemp3_f/rftemp2_f 138 | ; rm_eff_f(iz,it) = 3.0*rmtemp3_f/rmtemp2_f 139 | ; r_eff_s(iz,it) = 3.0*rtemp3_s/rtemp2_s 140 | ; endfor 141 | ; endfor 142 | 143 | !p.multi = [0,1,1] 144 | loadct, 39 145 | 146 | for it = 0, nt-1 do begin 147 | ; plot, r_eff_f[*,nt-1], z[*], yrange=[0,110], xrange=[1.0e-3,1.0e3],xstyle=1,/xlog,/nodata, $ 148 | ; title = 'time = '+string(time[it])+' seconds', charsize=1.2,$ 149 | ; xtitle='Effective Radius (um)', ytitle = 'Altitude [km]', thick=3, $ 150 | ; xtickname=['10!U-3!N','10!U-2!N','10!U-1!N','10!U0!N','10!U1!N','10!U2!N','10!U3!N'] 151 | ; oplot, r_eff_s[*,it], z[*], lin=0, thick=3 152 | ; oplot, r_eff_f[*,it], z[*], lin=2, thick=3, color=225 153 | ; oplot, rf_eff_f[*,it], z[*], lin=3, thick=3, color=125 154 | ; ;oplot, rm_eff_f[*,it], z[*], lin=1, thick=3 155 | ; 156 | 157 | 158 | 159 | 160 | ;plot, pctot_f[*,0], z[*], yrange=[0,110], xrange=[1.0e-3,1.0e3],/xlog,xstyle=1,/nodata, $ 161 | ; title = 'time = '+string(time[it])+' seconds', charsize=1.5, $ 162 | ; xtitle='Particle Concentration [# cm-3]', ytitle = 'Altitude [km]', thick=3 163 | ;oplot, pctot_f[*,it], z[*], lin=2, thick=3 164 | ;oplot, pctot_s[*,it], z[*], lin=0, thick=3 165 | 166 | 167 | plot, zmass_f[*,0], z[*], yrange=[0,80], xrange=[0,2.0e-10],xstyle=1, /nodata, $ 168 | title = 'time = '+string(time[it])+' seconds', charsize=1.2,$ 169 | xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=1 170 | 171 | oplot, zmass_s[*,it], z[*], lin=0, thick=3 172 | oplot, zmass_f[*,it], z[*], lin=0, thick=3, color=225 173 | 174 | xyouts, 0.15,0.89, "Fractal", color=225, /NORMAL, charsize=1.5 175 | xyouts, 0.15,0.84, "Spherical", /NORMAL, charsize=1.5 176 | 177 | wait, 0.01 178 | endfor 179 | 180 | 181 | end 182 | 183 | 184 | -------------------------------------------------------------------------------- /cmake/test_util.cmake: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Utility functions for creating tests 3 | 4 | if(CARMA_ENABLE_MEMCHECK) 5 | find_program(MEMORYCHECK_COMMAND "valgrind") 6 | endif() 7 | 8 | ################################################################################ 9 | # impose that one test runs after another so that we can safely test in parallel 10 | 11 | function(add_test_dependency run_second run_first) 12 | # add dependency between two tests 13 | # https://stackoverflow.com/a/66931930/5217293 14 | set_tests_properties(${run_first} PROPERTIES FIXTURES_SETUP f_${run_first}) 15 | set_tests_properties(${run_second} PROPERTIES FIXTURES_REQUIRED f_${run_first}) 16 | endfunction(add_test_dependency) 17 | 18 | ################################################################################ 19 | # build and add a standard test (one linked to the carma library) 20 | 21 | function(create_standard_test) 22 | set(prefix TEST) 23 | set(singleValues NAME WORKING_DIRECTORY) 24 | set(multiValues SOURCES) 25 | include(CMakeParseArguments) 26 | cmake_parse_arguments(${prefix} " " "${singleValues}" "${multiValues}" ${ARGN}) 27 | add_executable(test_${TEST_NAME} ${TEST_SOURCES}) 28 | set_target_properties(test_${TEST_NAME} PROPERTIES LINKER_LANGUAGE Fortran) 29 | target_link_libraries(test_${TEST_NAME} PUBLIC musica::carma GTest::gtest_main) 30 | if(CARMA_ENABLE_OPENMP) 31 | target_link_libraries(test_${TEST_NAME} PUBLIC OpenMP::OpenMP_Fortran) 32 | endif() 33 | if(CARMA_ENABLE_NETCDF) 34 | target_link_libraries(test_${TEST_NAME} PUBLIC PkgConfig::netcdfc PkgConfig::netcdff) 35 | endif() 36 | if(NOT DEFINED TEST_WORKING_DIRECTORY) 37 | set(TEST_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") 38 | endif() 39 | if(CARMA_ENABLE_LAPACK) 40 | target_link_libraries(test_${TEST_NAME} PUBLIC ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) 41 | endif() 42 | add_carma_test(${TEST_NAME} test_${TEST_NAME} "" ${TEST_WORKING_DIRECTORY}) 43 | endfunction(create_standard_test) 44 | 45 | ################################################################################ 46 | # build and add a standard test (one linked to the carma library) 47 | 48 | function(create_standard_cxx_test) 49 | set(prefix TEST) 50 | set(optionalValues SKIP_MEMCHECK) 51 | set(singleValues NAME WORKING_DIRECTORY) 52 | set(multiValues SOURCES LIBRARIES) 53 | 54 | include(CMakeParseArguments) 55 | cmake_parse_arguments(${prefix} "${optionalValues}" "${singleValues}" "${multiValues}" ${ARGN}) 56 | 57 | add_executable(test_${TEST_NAME} ${TEST_SOURCES}) 58 | target_link_libraries(test_${TEST_NAME} PUBLIC musica::carma GTest::gtest_main) 59 | 60 | if(CARMA_ENABLE_LAPACK) 61 | target_include_directories(test_${TEST_NAME} PUBLIC ${LAPACK_INCLUDE_DIRS}) 62 | target_link_libraries(test_${TEST_NAME} PUBLIC LAPACK::LAPACK ${LAPACKE_LIBRARIES}) 63 | endif() 64 | 65 | # link additional libraries 66 | foreach(library ${TEST_LIBRARIES}) 67 | target_link_libraries(test_${TEST_NAME} PUBLIC ${library}) 68 | endforeach() 69 | 70 | if(NOT DEFINED TEST_WORKING_DIRECTORY) 71 | set(TEST_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") 72 | endif() 73 | 74 | add_carma_test(${TEST_NAME} test_${TEST_NAME} "" ${TEST_WORKING_DIRECTORY} ${TEST_SKIP_MEMCHECK}) 75 | endfunction(create_standard_cxx_test) 76 | 77 | ################################################################################ 78 | # Add a test 79 | 80 | function(add_carma_test test_name test_binary test_args working_dir) 81 | if(CARMA_ENABLE_MPI) 82 | add_test(NAME ${test_name} 83 | COMMAND mpirun -v -np 2 ${CMAKE_BINARY_DIR}/${test_binary} ${test_args} 84 | WORKING_DIRECTORY ${working_dir}) 85 | else() 86 | add_test(NAME ${test_name} 87 | COMMAND ${test_binary} ${test_args} 88 | WORKING_DIRECTORY ${working_dir}) 89 | endif() 90 | set(MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1 --trace-children=yes --leak-check=full -s --gen-suppressions=all ${MEMCHECK_SUPPRESS}") 91 | set(memcheck "${MEMORYCHECK_COMMAND} ${MEMORYCHECK_COMMAND_OPTIONS}") 92 | separate_arguments(memcheck) 93 | if(CARMA_ENABLE_MPI AND MEMORYCHECK_COMMAND AND CARMA_ENABLE_MEMCHECK) 94 | add_test(NAME memcheck_${test_name} 95 | COMMAND mpirun -v -np 2 ${memcheck} ${CMAKE_BINARY_DIR}/${test_binary} ${test_args} 96 | WORKING_DIRECTORY ${working_dir}) 97 | elseif(MEMORYCHECK_COMMAND AND CARMA_ENABLE_MEMCHECK) 98 | add_test(NAME memcheck_${test_name} 99 | COMMAND ${memcheck} ${CMAKE_BINARY_DIR}/${test_binary} ${test_args} 100 | WORKING_DIRECTORY ${working_dir}) 101 | endif() 102 | endfunction(add_carma_test) 103 | 104 | ################################################################################ 105 | # Setup regression tests. Add dependencies between each regression test and its 106 | # memcheck test. Also add a dependence with any previous tests. Becuase CARMA 107 | # outputs to the same location, concurrent runs of the standalone tool that 108 | # depend on the output must run in serial 109 | 110 | function(add_regression_test test_name command memcheck_command) 111 | add_test(NAME ${test_name} COMMAND ${command} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 112 | 113 | if(MEMORYCHECK_COMMAND AND CARMA_ENABLE_MEMCHECK) 114 | add_test(NAME memcheck_${test_name} COMMAND ${memcheck_command} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 115 | endif() 116 | 117 | endfunction(add_regression_test) 118 | 119 | ################################################################################ 120 | # Link carma to a test and add it to the suite as a bash script 121 | 122 | macro(add_std_test_script test_name script_path) 123 | target_include_directories(${test_name} PUBLIC ${CMAKE_BINARY_DIR}/src) 124 | target_link_libraries(${test_name} PUBLIC musica::carma) 125 | if(CARMA_ENABLE_OPENMP) 126 | target_link_libraries(${test_name} PUBLIC OpenMP::OpenMP_Fortran) 127 | endif() 128 | add_test(NAME ${test_name} COMMAND ${script_path}) 129 | endmacro(add_std_test_script) 130 | 131 | ################################################################################ -------------------------------------------------------------------------------- /tests/read_bc2gtest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_bc2gtest.txt', /get_lun 2 | readf, lun, nbin, nelem, ngroup 3 | 4 | ; ibin_ = intarr(nbin) 5 | r = fltarr(nbin,ngroup) ; radius (cm) 6 | dr = fltarr(nbin,ngroup) ; delta radius (cm) 7 | data = fltarr(ngroup+1) 8 | 9 | for igroup = 0, ngroup-1 do begin 10 | for ibin = 0, nbin-1 do begin 11 | readf, lun, data 12 | ; ibin_[ibin] = fix( data[0] ) 13 | r[ibin,igroup] = data[1] 14 | dr[ibin,igroup] = data[2] 15 | endfor 16 | endfor 17 | 18 | data2 = fltarr(2) 19 | pc_ = fltarr(nbin,nelem) ; mass (g/cm^-3) in a bin 20 | 21 | 22 | nt = 0 23 | while(not(eof(lun))) do begin 24 | readf, lun, t1 25 | for ielem = 0, nelem-1 do begin 26 | for ibin = 0, nbin-1 do begin 27 | readf, lun, data2 28 | ; ibin_[ibin] = fix( data2[0] ) 29 | pc_[ibin,ielem] = data2[1] 30 | endfor 31 | endfor 32 | 33 | ; ibin = [ibin,ibin_] 34 | if (t1 eq 0.) then begin 35 | pc = pc_ 36 | time = t1 37 | endif else begin 38 | pc = [pc,pc_] 39 | time = [time,t1] 40 | endelse 41 | 42 | nt = nt+1 43 | endwhile 44 | 45 | free_lun, lun 46 | 47 | pc = reform(pc,nbin,nt,nelem) 48 | 49 | 50 | 51 | ; Map units for this test 52 | ; 3 elements: 1 - OC, 2 - BC shell, 3 - OC core 53 | ; Elements 1 - 2 are PC; element 3 is COREMASS 54 | ; For now, all elements have same size and mass dimensions 55 | d = 2.*r*1e4 56 | dd = 2.*dr*1e4 57 | 58 | dnlogd = alog(10.) * pc 59 | for ibin = 0, nbin-1 do begin 60 | dnlogd[ibin,*,0] = dnlogd[ibin,*,0]*d[ibin,0]/dd[ibin,0] 61 | dnlogd[ibin,*,1] = dnlogd[ibin,*,1]*d[ibin,0]/dd[ibin,0] 62 | endfor 63 | 64 | ; BCOC 65 | massbc = total(pc[*,*,1],1) - total(pc[*,*,2],1) 66 | massoc = total(pc[*,*,0],1) + total(pc[*,*,2],1) 67 | mass = massbc + massoc 68 | 69 | massmbc = total(pc[*,*,1],1) - total(pc[*,*,2],1) 70 | massmoc = total(pc[*,*,2],1) 71 | massmix = massmbc + massmoc 72 | 73 | 74 | ; Plot 75 | !p.font=0 76 | !p.multi = [0,1,2] 77 | loadct, 39 78 | 79 | ; Can't display 0 in log coordinates 80 | dnlogd[where(dnlogd le 0.)] = !Values.F_NAN 81 | 82 | for it = 0, nt-1 do begin 83 | plot, d[*,0], dnlogd[*,0,0], $ 84 | /xlog, /ylog, /nodata, xtitle = 'Diameter [um]', ytitle = 'dM/dlogD [g/cm3]', $ 85 | xrange=[.005,.3], yrange=[1.e-21,1.e-11], xstyle=1 86 | 87 | oplot, d[*,0], dnlogd[*,0,0], color=254, psym=2 88 | oplot, d[*,1], dnlogd[*,0,1], color=176, psym=4 89 | 90 | oplot, d[*,1], dnlogd[*,it,0], thick=6, color=254, lin=0 91 | oplot, d[*,0], dnlogd[*,it,1], thick=3, color=176, lin=0 92 | oplot, d[*,0], dnlogd[*,it,2], thick=3, color=84, lin=0 93 | 94 | xyouts, .1, 1.e-12, 'OC (pure group)', color=254 95 | xyouts, .1, 1.e-13, 'OC (core of mixed group)', color=84 96 | xyouts, .1, 1.e-14, 'BC (shell of mixed group)', color=176 97 | 98 | plot, [0.,1.], [mass[it], mass[it]], $ 99 | /nodata, ytitle = 'Total Mass Density [g/cm3]', $ 100 | yrange=[0.,2.5e-13], xstyle=1 101 | oplot, [0.,1.], [mass[it], mass[it]], thick=3, color=66, lin=0 102 | oplot, [0.,1.], [massoc[it], massoc[it]], thick=9, color=84, lin=0 103 | oplot, [0.,1.], [massbc[it], massbc[it]], thick=3, color=176, lin=0 104 | oplot, [0.,1.], [massmix[it], massmix[it]], thick=3, color=66, lin=2 105 | oplot, [0.,1.], [massmoc[it], massmoc[it]], thick=3, color=84, lin=2 106 | oplot, [0.,1.], [massmbc[it], massmbc[it]], thick=6, color=176, lin=2 107 | 108 | fac = 1./80. 109 | plots, fac*[50,55], 2.0e-13, thick=3, color=66 110 | plots, fac*[50,55], 1.8e-13, thick=3, color=66, lin=2 111 | xyouts, fac*57, 1.95e-13, 'Total Mass', color=66 112 | xyouts, fac*57, 1.75e-13, 'Mixed Group Mass', color=66 113 | 114 | plots, fac*[50,55], 0.9e-13, thick=3, color=176 115 | plots, fac*[50,55], 0.7e-13, thick=9, color=84 116 | plots, fac*[50,55], 0.5e-13, thick=6, color=176, lin=2 117 | plots, fac*[50,55], 0.3e-13, thick=3, color=84, lin=2 118 | xyouts, fac*57, 0.85e-13, 'Total BC', color=176 119 | xyouts, fac*57, 0.65e-13, 'Total OC', color=84 120 | xyouts, fac*57, 0.45e-13, 'Mixed BC', color=176 121 | xyouts, fac*57, 0.25e-13, 'Mixed OC', color=84 122 | 123 | wait, .1 124 | endfor 125 | 126 | ; At the end, show the mass evolution. 127 | plot, d[*,0], dnlogd[*,0,0], $ 128 | /xlog, /ylog, /nodata, xtitle = 'Diameter [um]', ytitle = 'dM/dlogD [g/cm3]', $ 129 | xrange=[.005,.3], yrange=[1.e-21,1.e-11], xstyle=1 130 | 131 | oplot, d[*,0], dnlogd[*,0,0], color=254, psym=2 132 | oplot, d[*,1], dnlogd[*,0,1], color=176, psym=4 133 | 134 | oplot, d[*,1], dnlogd[*,it-1,0], thick=6, color=254, lin=0 135 | oplot, d[*,0], dnlogd[*,it-1,1], thick=3, color=176, lin=0 136 | oplot, d[*,0], dnlogd[*,it-1,2], thick=3, color=84, lin=0 137 | 138 | xyouts, .1, 1.e-12, 'OC (pure group)', color=254 139 | xyouts, .1, 1.e-13, 'OC (core of mixed group)', color=84 140 | xyouts, .1, 1.e-14, 'BC (shell of mixed group)', color=176 141 | 142 | 143 | plot, mass, xtitle = 'Time Step', ytitle = 'Total Mass Density [g/cm3]' 144 | oplot, mass, thick=3, color=66, lin=0 145 | oplot, massoc, thick=9, color=84, lin=0 146 | oplot, massbc, thick=3, color=176, lin=0 147 | oplot, massmix, thick=3, color=66, lin=2 148 | oplot, massmoc, thick=3, color=84, lin=2 149 | oplot, massmbc, thick=6, color=176, lin=2 150 | 151 | plots, [50,55], 2.0e-13, thick=3, color=66 152 | plots, [50,55], 1.8e-13, thick=3, color=66, lin=2 153 | xyouts, 57, 1.95e-13, 'Total Mass', color=66 154 | xyouts, 57, 1.75e-13, 'Mixed Group Mass', color=66 155 | 156 | plots, [50,55], 0.9e-13, thick=3, color=176 157 | plots, [50,55], 0.7e-13, thick=9, color=84 158 | plots, [50,55], 0.5e-13, thick=6, color=176, lin=2 159 | plots, [50,55], 0.3e-13, thick=3, color=84, lin=2 160 | xyouts, 57, 0.85e-13, 'Total BC', color=176 161 | xyouts, 57, 0.65e-13, 'Total OC', color=84 162 | xyouts, 57, 0.45e-13, 'Mixed BC', color=176 163 | xyouts, 57, 0.25e-13, 'Mixed OC', color=84 164 | 165 | 166 | end 167 | -------------------------------------------------------------------------------- /tests/read_growtest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_growtest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | mmrgas_ = fltarr(ngas) 23 | satliq_ = fltarr(ngas) 24 | satice_ = fltarr(ngas) 25 | 26 | data = fltarr(3) 27 | datag = fltarr(4) 28 | 29 | t_ = 0. 30 | rlheat_ = 0. 31 | 32 | nt = 0L 33 | while(not(eof(lun))) do begin 34 | readf, lun, t1 35 | 36 | readf, lun, t_, rlheat_ 37 | 38 | for ielem = 0, nelem-1 do begin 39 | for ibin = 0, nbin-1 do begin 40 | readf, lun, data 41 | 42 | mmr_[ielem, ibin] = data[2] 43 | endfor 44 | endfor 45 | 46 | if (nt eq 0) then begin 47 | time = t1 48 | mmr = mmr_ 49 | t = t_ 50 | rlheat = rlheat_ 51 | endif else begin 52 | time = [time,t1] 53 | mmr = [mmr,mmr_] 54 | t = [t,t_] 55 | rlheat = [rlheat,rlheat_] 56 | endelse 57 | 58 | for igas = 0, ngas-1 do begin 59 | readf, lun, datag 60 | 61 | mmrgas_[igas] = datag[1] 62 | satliq_[igas] = datag[2] 63 | satice_[igas] = datag[3] 64 | endfor 65 | 66 | if (nt eq 0) then begin 67 | mmrgas = mmrgas_ 68 | satliq = satliq_ 69 | satice = satice_ 70 | endif else begin 71 | mmrgas = [mmrgas,mmrgas_] 72 | satliq = [satliq,satliq_] 73 | satice = [satice,satice_] 74 | endelse 75 | 76 | nt = nt+1 77 | endwhile 78 | 79 | free_lun, lun 80 | 81 | mmr = reform(mmr,nelem,nt,nbin) 82 | mmrgas = reform(mmrgas,nt,ngas) 83 | satliq = reform(satliq,nt,ngas) 84 | satice = reform(satice,nt,ngas) 85 | 86 | !p.multi = [0,1,5] 87 | loadct, 39 88 | 89 | ;Calculate the column mass, which should be conserved. 90 | mmrelem = fltarr(nt,nelem) 91 | mmrtotal = fltarr(nt) 92 | 93 | for ielem = 0, nelem-1 do begin 94 | for it = 0L, nt-1 do begin 95 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 96 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 97 | endfor 98 | endfor 99 | 100 | mmr[where(mmr le 0.)] = !Values.F_NAN 101 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 102 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 103 | satliq[0,*] = !Values.F_NAN 104 | satice[0,*] = !Values.F_NAN 105 | 106 | for it = 0L, nt-1 do begin 107 | plot, r[*], mmr[0,0,*], yrange=[1e-30, 10*max(mmrtotal)], $ 108 | title = 'time = '+string(time[it])+' seconds', $ 109 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=3, $ 110 | /XLOG, /YLOG, charsize=2.0 111 | 112 | ; Add a legend 113 | plots, [60,62], 1e-10, thick=3, lin=0, color=66 114 | plots, [60,62], 1e-5, thick=3, lin=0, color=96 115 | xyouts, 63, 1e-10, 'Ice', color=66 116 | xyouts, 63, 1e-5, 'Water Vapor', color=96 117 | 118 | for ielem = 0, nelem-1 do begin 119 | oplot, r[*], mmr[ielem,it,*], lin=ielem, thick=3, color=66 120 | endfor 121 | 122 | for igas = 0, ngas-1 do begin 123 | oplot, [min(r), max(r)], [mmrgas[it, igas], mmrgas[it, igas]], thick=3, color=96, lin=igas 124 | endfor 125 | 126 | ; Show the mmr evolution. 127 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=3, $ 128 | title = 'Total mmr evolution', charsize=2.0, $ 129 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 130 | 131 | ; Add a legend 132 | plots, [2,2.5], 5.5e-6, thick=3, lin=0, color=66 133 | plots, [4,4.5], 5.5e-6, thick=3, lin=0, color=96 134 | plots, [9,9.5], 5.5e-6, thick=3, lin=0, color=26 135 | xyouts, 2.7, 5.25e-6, 'Ice', color=66 136 | xyouts, 4.7, 5.25e-6, 'Water Vapor', color=96 137 | xyouts, 9.7, 5.25e-6, 'Total Water', color=26 138 | 139 | 140 | for ielem = 0, nelem-1 do begin 141 | oplot, mmrelem[*,ielem], thick=3, lin=ielem 142 | endfor 143 | for igas = 0, ngas-1 do begin 144 | oplot, mmrgas[*,igas], thick=3, lin=igas 145 | endfor 146 | 147 | oplot, mmrtotal[0:it], thick=3, color=26 148 | 149 | for ielem = 0, nelem-1 do begin 150 | oplot, mmrelem[0:it,ielem], thick=3, color=66, lin=ielem 151 | endfor 152 | 153 | for igas = 0, ngas-1 do begin 154 | oplot, mmrgas[0:it, igas], thick=3, color=96, lin=igas 155 | endfor 156 | 157 | ; Show the saturation evolution. 158 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=3, $ 159 | title = 'Gas Saturation Ratio', $ 160 | yrange=[0, 5], charsize=2.0 161 | 162 | ; Add a legend 163 | plots, [2,2.5], 4.5, thick=3, lin=0, color=66 164 | plots, [2,2.5], 3.5, thick=3, lin=0, color=196 165 | xyouts, 2.7, 4.25, 'Sat Ice', color=66 166 | xyouts, 2.7, 3.25, 'Sat Liq', color=196 167 | 168 | oplot, [0, nt], [1., 1.], thick=3 169 | 170 | for igas = 0, ngas-1 do begin 171 | oplot, satliq[*,igas], thick=3, lin=igas 172 | oplot, satice[*,igas], thick=3, lin=igas 173 | endfor 174 | 175 | for igas = 0, ngas-1 do begin 176 | oplot, satliq[0:it, igas], thick=3, color=196, lin=igas 177 | oplot, satice[0:it, igas], thick=3, color=66, lin=igas 178 | endfor 179 | 180 | ; Show the temperature evolution. 181 | plot, t[*], xtitle = 'Time Step', ytitle = 'dT (K)', thick=3, $ 182 | title = 'Delta Temperature', $ 183 | yrange=[0., max(t)], charsize=2.0 184 | 185 | oplot, t[0:it], thick=3, lin=0, color=66 186 | 187 | ; Show the latent heat. 188 | plot, rlheat[*], xtitle = 'Time Step', ytitle = 'LH (K/s)', thick=3, $ 189 | title = 'Latent Heat', $ 190 | yrange=[min(rlheat), max(rlheat)], charsize=2.0 191 | 192 | oplot, rlheat[0:it], thick=3, lin=0, color=66 193 | 194 | wait, 2. / nt 195 | endfor 196 | 197 | end 198 | -------------------------------------------------------------------------------- /tests/carma_mietest.F90: -------------------------------------------------------------------------------- 1 | !! This code is to demonstrate the CARMA mie routines. 2 | !! 3 | !! Upon execution, a text file (carma_mietest.txt) is generated. 4 | !! The text file can be read with the IDL procedure read_mietest.pro. 5 | !! 6 | !! @author Chuck Bardeen 7 | !! @version May-2009 8 | 9 | program carma_mietest 10 | implicit none 11 | 12 | write(*,*) "Mie Test" 13 | 14 | call test_mie() 15 | 16 | write(*,*) "Done" 17 | end program 18 | 19 | 20 | subroutine test_mie() 21 | use carma_precision_mod 22 | use carma_constants_mod 23 | use carma_enums_mod 24 | use carma_types_mod 25 | use carmaelement_mod 26 | use carmagroup_mod 27 | use carmastate_mod 28 | use carma_mod 29 | 30 | implicit none 31 | 32 | integer, parameter :: NELEM = 1 33 | integer, parameter :: NBIN = 16 34 | integer, parameter :: NGROUP = 1 35 | integer, parameter :: NSOLUTE = 0 36 | integer, parameter :: NGAS = 0 37 | integer, parameter :: NWAVE = 44 38 | integer, parameter :: NREFIDX = 1 !! Number of refractive indices per element 39 | 40 | integer, parameter :: I_DUST = 1 41 | 42 | type(carma_type), target :: carma 43 | type(carma_type), pointer :: carma_ptr 44 | integer :: rc = 0 45 | 46 | 47 | integer :: i 48 | integer :: ielem 49 | integer :: iwave 50 | integer :: ibin 51 | integer :: igroup 52 | integer, parameter :: lun = 42 53 | 54 | real(kind=f) :: rmin, rmrat, rho 55 | 56 | real(kind=f) :: wave(NWAVE) 57 | complex(kind=f) :: refidx(NWAVE, NREFIDX) 58 | real(kind=f) :: r_refidx(NWAVE) 59 | real(kind=f) :: i_refidx(NWAVE) 60 | real(kind=f) :: qext(NWAVE, NBIN) 61 | real(kind=f) :: ssa(NWAVE, NBIN) 62 | real(kind=f) :: asym(NWAVE, NBIN) 63 | real(kind=f) :: r(NBIN) 64 | 65 | ! Set the wavelengths 66 | data wave & 67 | / 0.340_f, 0.380_f, 0.412_f, 0.440_f, 0.443_f, 0.490_f, & 68 | 0.500_f, 0.531_f, 0.532_f, 0.551_f, 0.555_f, 0.667_f, & 69 | 0.675_f, 0.870_f, 1.020_f, 1.640_f, 1.111_f, 1.333_f, & 70 | 1.562_f, 1.770_f, 2.051_f, 2.210_f, 2.584_f, 3.284_f, & 71 | 3.809_f, 4.292_f, 4.546_f, 4.878_f, 5.128_f, 5.405_f, & 72 | 5.714_f, 6.061_f, 6.452_f, 6.897_f, 7.407_f, 8.333_f, & 73 | 9.009_f, 10.309_f, 12.500_f, 13.889_f, 16.667_f, 20.000_f, & 74 | 26.316_f, 35.714_f / 75 | 76 | data r_refidx & 77 | / 1.343_f, 1.341_f, 1.339_f, 1.337_f, 1.337_f, 1.335_f, & 78 | 1.335_f, 1.334_f, 1.334_f, 1.333_f, 1.333_f, 1.331_f, & 79 | 1.331_f, 1.329_f, 1.327_f, 1.317_f, 1.327_f, 1.323_f, & 80 | 1.319_f, 1.313_f, 1.305_f, 1.295_f, 1.252_f, 1.455_f, & 81 | 1.362_f, 1.334_f, 1.326_f, 1.320_f, 1.308_f, 1.283_f, & 82 | 1.278_f, 1.313_f, 1.326_f, 1.310_f, 1.293_f, 1.270_f, & 83 | 1.227_f, 1.164_f, 1.173_f, 1.287_f, 1.415_f, 1.508_f, & 84 | 1.541_f, 1.669_f / 85 | 86 | data i_refidx & 87 | / 6.5e-9_f, 4.0e-9_f, 1.86e-9_f, 1.02e-9_f, 1.02e-9_f, 1.0e-9_f, & 88 | 1.0e-9_f, 1.5e-9_f, 1.5e-9_f, 1.96e-9_f, 1.96e-9_f, 3.35e-8_f, & 89 | 3.35e-8_f, 2.93e-7_f, 2.89e-6_f, 8.55e-5_f, 2.05E-06_f, 2.39E-05, & 90 | 1.20E-04_f, 1.18E-04_f, 6.79E-04_f, 3.51E-04_f, 2.39E-03_f, 0.0442_f, & 91 | 0.00339_f, 0.00833_f, 0.0139_f, 0.0125_f, 0.011_f, 0.015_f, & 92 | 0.075_f, 0.086_f, 0.039_f, 0.035_f, 0.035_f, 0.038, & 93 | 0.051_f, 0.161_f, 0.308_f, 0.39_f, 0.42_f, 0.395_f, & 94 | 0.373_f, 0.5_f / 95 | 96 | 97 | ! write(*,*) "" 98 | ! write(*,*) "Mie Calculations" 99 | 100 | ! Open the output text file 101 | open(unit=lun,file="carma_mietest.txt",status="unknown") 102 | 103 | ! Convert wavelength um -> cm 104 | wave = wave * 1e-4_f 105 | 106 | ! Construct a complex refractive index. 107 | refidx(:,1) = cmplx(r_refidx(:), i_refidx(:), kind=f) 108 | 109 | ! Define the particle-grid extent of the CARMA test 110 | ! write(*,*) " CARMA_Create(carma, ", NBIN, ", ", NELEM, ", ", NGROUP, & 111 | ! ", ", NSOLUTE, ", ", NGAS, ", rc, 6) ..." 112 | call CARMA_Create(carma, NBIN, NELEM, NGROUP, NSOLUTE, NGAS, NWAVE, rc, LUNOPRT=6, wave=wave, NREFIDX=NREFIDX) 113 | if (rc < 0) stop " *** FAILED ***" 114 | carma_ptr => carma 115 | 116 | 117 | ! Define the group 118 | rho = 2.65_f 119 | rmrat = 4.32_f 120 | rmin = 1e-6_f 121 | ! write(*,*) " Add Group(s) ..." 122 | call CARMAGROUP_Create(carma, 1, "dust", rmin, rmrat, & 123 | I_SPHERE, 1._f, .FALSE., rc, do_mie=.true.) 124 | if (rc < 0) stop " *** FAILED ***" 125 | 126 | 127 | ! Define the element 128 | ! write(*,*) " Add Element(s) ..." 129 | call CARMAELEMENT_Create(carma, 1, 1, "dust", rho, I_INVOLATILE, I_DUST, rc, refidx=refidx) 130 | if (rc < 0) stop " *** FAILED ***" 131 | 132 | 133 | ! Setup the CARMA processes to exercise 134 | ! write(*,*) " Initialize ..." 135 | call CARMA_Initialize(carma, rc, do_pheat=.true.) 136 | if (rc < 0) stop " *** FAILED ***" 137 | 138 | 139 | ! Print the Group Information 140 | ! write(*,*) "" 141 | ! call dumpGroup(carma, rc) 142 | ! if (rc < 0) stop " *** FAILED ***" 143 | 144 | ! Print the Element Information 145 | ! write(*,*) "" 146 | ! call dumpElement(carma, rc) 147 | ! if (rc < 0) stop " *** FAILED ***" 148 | 149 | ! write(*,*) "" 150 | 151 | ! Write output for the falltest 152 | write(lun,*) NGROUP, NWAVE, NBIN 153 | 154 | do iwave = 1, NWAVE 155 | write(lun,'(i3,e10.3)') iwave, wave(iwave) 156 | end do 157 | 158 | do igroup = 1, NGROUP 159 | 160 | call CARMAGROUP_Get(carma, igroup, rc, r=r, qext=qext, ssa=ssa, asym=asym) 161 | 162 | do ibin = 1, NBIN 163 | write(lun,'(i3,e10.3)') ibin, r(ibin) 164 | end do 165 | 166 | do iwave = 1, NWAVE 167 | write(lun,'(i3,2e10.3)') iwave, refidx(iwave,1) 168 | end do 169 | 170 | do iwave = 1, NWAVE 171 | do ibin = 1, NBIN 172 | write(lun,'(2i3,3(x,e10.3))') iwave, ibin, qext(iwave,ibin), ssa(iwave,ibin), asym(iwave,ibin) 173 | end do 174 | end do 175 | end do 176 | 177 | ! Close the output file 178 | close(unit=lun) 179 | 180 | ! write(*,*) "" 181 | ! write(*,*) " CARMA_Destroy() ..." 182 | call CARMA_Destroy(carma, rc) 183 | if (rc /=0) stop " *** FAILED ***" 184 | end subroutine 185 | -------------------------------------------------------------------------------- /tests/read_sulfatetest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_sulfatetest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | mmrgas_ = fltarr(ngas) 23 | satliq_ = fltarr(ngas) 24 | satice_ = fltarr(ngas) 25 | 26 | data = fltarr(3) 27 | datag = fltarr(4) 28 | 29 | t_ = 0. 30 | nsubstep_ = 0 31 | nretry_ = 0 32 | 33 | nt = 0 34 | while(not(eof(lun))) do begin 35 | readf, lun, t1 36 | 37 | readf, lun, nsubstep_, nretry_, t_ 38 | 39 | for ielem = 0, nelem-1 do begin 40 | for ibin = 0, nbin-1 do begin 41 | readf, lun, data 42 | 43 | mmr_[ielem, ibin] = data[2] 44 | endfor 45 | endfor 46 | 47 | if (nt eq 0) then begin 48 | time = t1 49 | mmr = mmr_ 50 | nsubstep = nsubstep_ 51 | nretry = nretry_ 52 | t = t_ 53 | endif else begin 54 | time = [time,t1] 55 | mmr = [mmr,mmr_] 56 | nsubstep = [nsubstep,nsubstep_] 57 | nretry = [nretry,nretry_] 58 | t = [t,t_] 59 | endelse 60 | 61 | for igas = 0, ngas-1 do begin 62 | readf, lun, datag 63 | 64 | mmrgas_[igas] = datag[1] 65 | satliq_[igas] = datag[2] 66 | satice_[igas] = datag[3] 67 | endfor 68 | 69 | if (nt eq 0) then begin 70 | mmrgas = mmrgas_ 71 | satliq = satliq_ 72 | satice = satice_ 73 | endif else begin 74 | mmrgas = [mmrgas,mmrgas_] 75 | satliq = [satliq,satliq_] 76 | satice = [satice,satice_] 77 | endelse 78 | 79 | nt = nt+1 80 | endwhile 81 | 82 | free_lun, lun 83 | 84 | mmr = reform(mmr,nelem,nt,nbin) 85 | mmrgas = reform(mmrgas,ngas,nt) 86 | satliq = reform(satliq,ngas, nt) 87 | satice = reform(satice,ngas, nt) 88 | 89 | nsubstep[0] = !values.f_nan 90 | nretry[0] = !values.f_nan 91 | 92 | !p.multi = [0,1,5] 93 | loadct, 39 94 | 95 | ;Calculate the column mass, which should be conserved. 96 | mmrelem = fltarr(nt,nelem) 97 | mmrtotal = fltarr(nt) 98 | 99 | for ielem = 0, nelem-1 do begin 100 | for it = 0, nt-1 do begin 101 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 102 | mmrtotal[it] = total(mmrelem[it,*]) + mmrgas[1, it] 103 | endfor 104 | endfor 105 | 106 | mmr[where(mmr le 0.)] = !Values.F_NAN 107 | ;mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 108 | ;mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 109 | ; satliq[where(satliq le 0.)] = !Values.F_NAN 110 | ; satice[where(satice le 0.)] = !Values.F_NAN 111 | satliq[*, 0] = !Values.F_NAN 112 | satice[*, 0] = !Values.F_NAN 113 | 114 | 115 | for it = 0, nt-1 do begin 116 | ; ======plot 1 ============== 117 | plot, r[*], mmr[0,0,*], yrange=[1e-35, 10*max(mmrtotal)], $ 118 | title = 'time = '+string(time[it])+' seconds', $ 119 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=6, $ 120 | /XLOG, /YLOG, charsize=2.0 121 | 122 | ; Add a legend 123 | ; plots, [1.5e-10,1.75e-10], 1.0, thick=3, color=66, lin=0 124 | ; plots, [1.5e-10,1.75e-10], 1.0, thick=3, color=66, lin=1 125 | ; plots, [1.5e-10,1.75e-10], 1.2, thick=3, color=66, lin=2 126 | ; xyouts, 1.8e-10, 4.2, 'sulfate mmr', color=66 127 | ; xyouts, 1.8e-10, 2.7, 'gas mmr', color=96 128 | ; xyouts, 1.8e-10, 1.2, 'Gerber', color=66 129 | 130 | 131 | oplot, r[*], mmr[0,it,*], thick=6, color=66 ; Sulfates, darkblue 132 | 133 | oplot, [min(r), max(r)], [mmrgas[1, it], mmrgas[1, it]], thick=6, color=96 ; H2SO4 gas, light blue 134 | 135 | 136 | ; ======plot 2 ============== 137 | ; Show the mmr evolution. 138 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=6, $ 139 | title = 'Total mmr evolution', charsize=2.0, $ 140 | xrange=[0,nt-1], $ 141 | yrange=[0., 1.5*max(mmrtotal[*])] 142 | 143 | ; Add a legend 144 | plots, [nt/25., nt/25.+1.], 1.4*max(mmrtotal[*]), thick=3, lin=0, color=66 145 | plots, [5.*nt/50.,5.*nt/50.+1.], 1.4*max(mmrtotal[*]), thick=3, lin=0, color=96 146 | plots, [11.*nt/50.,11.*nt/50.+1.], 1.4*max(mmrtotal[*]), thick=3, lin=0, color=26 147 | xyouts, nt/25.+1.5, 1.3*max(mmrtotal[*]), 'Sulfate', color=66 148 | xyouts, 5.*nt/50.+1.5, 1.3*max(mmrtotal[*]), 'Sulfate Gas', color=96 149 | xyouts, 11.*nt/50.+1.5, 1.3*max(mmrtotal[*]), 'Total H2SO4', color=26 150 | 151 | oplot, mmrelem[*,0], thick=6 ; Sulfates, trajectory 152 | 153 | 154 | oplot, mmrgas[1,*], thick=6 ; H2SO4 gas, trajectory 155 | 156 | 157 | oplot, mmrtotal[0:it], thick=6, color=26 ; Total H2SO4, purple 158 | 159 | 160 | oplot, mmrelem[0:it,0], thick=6, color=66 ; Sulfates, dark blue 161 | 162 | 163 | oplot, mmrgas[1, 0:it], thick=6, color=96 ; H2SO4 gas, light blue 164 | 165 | ; ======plot 3 ============== 166 | ; Show the saturation evolution. 167 | plot, satliq[*, 2], xtitle = 'Time Step', ytitle = 's', thick=6, $ 168 | title = 'Gas Saturation Ratio', $ 169 | xrange=[0,nt-1], yrange=[0,max(satliq, /NAN)], charsize=2.0 170 | 171 | oplot, satliq[1, *], thick=6 172 | oplot, satice[1, *], thick=6 173 | 174 | oplot, satliq[1, 0:it], thick=6, color=196 ; liquid, yellow 175 | 176 | ; Show the substepping evolution. 177 | plot, nsubstep[0:*], xtitle = 'Time Step', ytitle = 'Nsubsteps', thick=6, $ 178 | title = 'Number of Substeps', $ 179 | yrange=[0., 1.2*max(nsubstep)], charsize=2.0 180 | 181 | oplot, nsubstep[0:it], thick=6, lin=0, color=66 182 | 183 | ; Show the retry evolution. 184 | plot, nretry[0:*], xtitle = 'Time Step', ytitle = 'Nretry', thick=6, $ 185 | title = 'Number of Retries', $ 186 | charsize=2.0 187 | 188 | oplot, nretry[0:it], thick=6, lin=0, color=66 189 | 190 | wait, 15. / nt 191 | endfor 192 | 193 | end 194 | -------------------------------------------------------------------------------- /tests/carma_fractalopticstest.F90: -------------------------------------------------------------------------------- 1 | !! This code is to demonstrate the CARMA optical treatment of 2 | !! fractal aggregates composed of identical spheres. 3 | !! 4 | !! Upon execution, a text file (carma_fractalopticstest.txt) is generated. 5 | !! The text file can be read with the IDL procedure read_fractalopticstest.pro. 6 | !! 7 | !! @author Eric Wolf (based on Chuck Bardeen's code) 8 | !! @version March-2013 9 | 10 | program carma_fractalopticstest 11 | implicit none 12 | 13 | write(*,*) "Fractal Optics Test" 14 | 15 | call test_fractaloptics() 16 | 17 | write(*,*) "Done" 18 | end program 19 | 20 | 21 | subroutine test_fractaloptics() 22 | use carma_precision_mod 23 | use carma_constants_mod 24 | use carma_enums_mod 25 | use carma_types_mod 26 | use carmaelement_mod 27 | use carmagroup_mod 28 | use carmastate_mod 29 | use carma_mod 30 | 31 | implicit none 32 | 33 | integer, parameter :: NELEM = 1 34 | integer, parameter :: NBIN = 1 35 | integer, parameter :: NGROUP = 1 36 | integer, parameter :: NSOLUTE = 0 37 | integer, parameter :: NGAS = 0 38 | integer, parameter :: NWAVE = 10 39 | integer, parameter :: NRUN = 2 40 | integer, parameter :: NREFIDX = 1 !! Number of refractive indices per element 41 | 42 | integer, parameter :: I_DUST = 1 43 | 44 | type(carma_type), target :: carma 45 | type(carma_type), pointer :: carma_ptr 46 | integer :: rc = 0 47 | 48 | 49 | integer :: i 50 | integer :: ielem 51 | integer :: iwave 52 | integer :: ibin 53 | integer :: igroup 54 | integer :: irun 55 | integer, parameter :: lun = 42 56 | 57 | real(kind=f) :: rmin, rmrat, rho, rmon, nmon, falpha 58 | 59 | real(kind=f) :: wave(NWAVE) 60 | complex(kind=f) :: refidx(NWAVE, NREFIDX) 61 | real(kind=f) :: r_refidx(NWAVE) 62 | real(kind=f) :: i_refidx(NWAVE) 63 | real(kind=f) :: qext_data(NRUN, NWAVE, NBIN) 64 | real(kind=f) :: ssa_data(NRUN, NWAVE, NBIN) 65 | real(kind=f) :: asym_data(NRUN, NWAVE, NBIN) 66 | real(kind=f) :: qext(NWAVE, NBIN) 67 | real(kind=f) :: ssa(NWAVE, NBIN) 68 | real(kind=f) :: asym(NWAVE, NBIN) 69 | real(kind=f) :: r(NBIN) 70 | real(kind=f) :: df(NBIN) 71 | 72 | data wave /0.1181_f, 0.1362_f, 0.1968_f, 0.2952_f, 0.4133_f, 0.5635_f, 0.6888_f, 0.8731_f, 1.016_f, 2.019_f/ 73 | data r_refidx /1.75_f, 1.70_f, 1.66_f, 1.66_f, 1.69_f, 1.70_f, 1.68_f, 1.66_f, 1.65_f, 1.63_f/ 74 | data i_refidx /0.40_f, 0.27_f, 0.22_f, 0.15_f, 0.076_f, 0.023_f, 0.0088_f, 0.0024_f, 0.001_f, 0.00072_f/ 75 | 76 | ! write(*,*) "" 77 | ! write(*,*) "Calculations" 78 | 79 | ! Open the output text file 80 | open(unit=lun,file="carma_fractalopticstest.txt",status="unknown") 81 | 82 | ! Convert wavelength um -> cm 83 | wave = wave * 1e-4_f 84 | 85 | ! Construct a complex refractive index. 86 | refidx(:,1) = cmplx(r_refidx(:), i_refidx(:), kind=f) 87 | 88 | 89 | do irun=1,NRUN 90 | 91 | ! Define the particle-grid extent of the CARMA test 92 | call CARMA_Create(carma, NBIN, NELEM, NGROUP, NSOLUTE, NGAS, NWAVE, rc, LUNOPRT=6, wave=wave, NREFIDX=NREFIDX) 93 | if (rc < 0) stop " *** CARMA_Create FAILED ***" 94 | carma_ptr => carma 95 | 96 | ! Define the groups 97 | rho = 2.65_f ! [g cm-3] 98 | rmrat = 2.5_f 99 | df(:) = 2.0_f 100 | rmon = 50.0e-7_f ! [cm] 101 | nmon = 100._f 102 | rmin = nmon**(1._f/3._f)*rmon 103 | falpha = 1.1_f 104 | 105 | if (irun .EQ. 1) then ! do fractal optics calulcation 106 | call CARMAGROUP_Create(carma, 1, "fractal", rmin, rmrat, & 107 | I_SPHERE, 1._f, .FALSE., rc, is_fractal=.TRUE., & 108 | do_mie=.true., imiertn=I_MIERTN_BOTET1997, & 109 | rmon=rmon, df=df, falpha=falpha) 110 | 111 | if (rc < 0) stop " *** irun 1 CARMAGROUP_Create FAILED ***" 112 | ! Define the element 113 | call CARMAELEMENT_Create(carma, 1, 1, "dust", rho, I_INVOLATILE, I_DUST, rc, refidx=refidx ) 114 | if (rc < 0) stop " *** irun 1 CARMAELEMENT_Create FAILED ***" 115 | end if 116 | 117 | if (irun .EQ. 2) then ! do standard mie calculation for comparison 118 | call CARMAGROUP_Create(carma, 1, "sphere", rmin, rmrat, & 119 | I_SPHERE, 1._f, .FALSE., rc, is_fractal=.FALSE., & 120 | do_mie=.true., imiertn=I_MIERTN_TOON1981) 121 | if (rc < 0) stop " *** irun 2 CARMAGROUP_CreateFAILED ***" 122 | ! Define the element 123 | call CARMAELEMENT_Create(carma, 1, 1, "dust", rho, I_INVOLATILE, I_DUST, rc, refidx=refidx ) 124 | if (rc < 0) stop " *** irun 2 CARMAELEMENT_Create FAILED ***" 125 | endif 126 | 127 | 128 | ! Setup the CARMA processes to exercise 129 | call CARMA_Initialize(carma, rc, do_pheat=.TRUE.) 130 | if (rc < 0) stop " *** CARMA_Initialize FAILED ***" 131 | do igroup = 1, NGROUP 132 | call CARMAGROUP_Get(carma, igroup, rc, r=r, qext=qext, ssa=ssa, asym=asym) 133 | do iwave = 1, NWAVE 134 | do ibin = 1, NBIN 135 | qext_data(irun,iwave,ibin) = qext(iwave,ibin) 136 | ssa_data(irun,iwave,ibin) = ssa(iwave,ibin) 137 | asym_data(irun,iwave,ibin) = asym(iwave,ibin) 138 | end do 139 | end do 140 | end do 141 | 142 | 143 | ! write(*,*) "" 144 | ! write(*,*) " CARMA_Destroy() ..." 145 | call CARMA_Destroy(carma, rc) 146 | if (rc /=0) stop " *** CARMA_Destroy FAILED ***" 147 | end do ! irun 148 | 149 | ! Write grid parameters 150 | write(lun,*) NGROUP, NWAVE, NBIN 151 | 152 | do iwave = 1, NWAVE 153 | write(lun,'(i3,e10.3)') iwave, wave(iwave) 154 | end do 155 | 156 | do ibin = 1, NBIN 157 | write(lun,'(i3,e10.3)') ibin, r(ibin) 158 | end do 159 | 160 | do iwave = 1, NWAVE 161 | write(lun,'(i3,2e10.3)') iwave, refidx(iwave,1) 162 | end do 163 | 164 | do iwave = 1, NWAVE 165 | do ibin = 1, NBIN 166 | write(lun,'(2i3,6(x,e10.3))') iwave, ibin, qext_data(1,iwave,ibin), ssa_data(1,iwave,ibin), asym_data(1,iwave,ibin), & 167 | qext_data(2,iwave,ibin), ssa_data(2,iwave,ibin), asym_data(2,iwave,ibin) 168 | end do 169 | end do 170 | 171 | ! Close the output file 172 | close(unit=lun) 173 | 174 | end subroutine 175 | -------------------------------------------------------------------------------- /tests/read_pheattest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_pheattest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | dtpart_ = fltarr(nelem, nbin) 23 | mmrgas_ = fltarr(ngas) 24 | satliq_ = fltarr(ngas) 25 | satice_ = fltarr(ngas) 26 | t_ = fltarr(1) 27 | 28 | data = fltarr(4) 29 | datag = fltarr(4) 30 | datat = fltarr(1) 31 | 32 | nt = 0 33 | while(not(eof(lun))) do begin 34 | readf, lun, t1 35 | for ielem = 0, nelem-1 do begin 36 | for ibin = 0, nbin-1 do begin 37 | readf, lun, data 38 | 39 | mmr_[ielem, ibin] = data[2] 40 | dtpart_[ielem, ibin] = data[3] 41 | endfor 42 | endfor 43 | 44 | if (nt eq 0) then begin 45 | time = t1 46 | mmr = mmr_ 47 | dtpart = dtpart_ 48 | endif else begin 49 | time = [time,t1] 50 | mmr = [mmr,mmr_] 51 | dtpart = [dtpart,dtpart_] 52 | endelse 53 | 54 | for igas = 0, ngas-1 do begin 55 | readf, lun, datag 56 | 57 | mmrgas_[igas] = datag[1] 58 | satliq_[igas] = datag[2] 59 | satice_[igas] = datag[3] 60 | endfor 61 | 62 | readf, lun, datat 63 | t_ = datat 64 | 65 | if (nt eq 0) then begin 66 | mmrgas = mmrgas_ 67 | satliq = satliq_ 68 | satice = satice_ 69 | t = t_ 70 | endif else begin 71 | mmrgas = [mmrgas,mmrgas_] 72 | satliq = [satliq,satliq_] 73 | satice = [satice,satice_] 74 | t = [t, t_] 75 | endelse 76 | 77 | nt = nt+1 78 | endwhile 79 | 80 | free_lun, lun 81 | 82 | mmr = reform(mmr,nelem,nt,nbin) 83 | dtpart = reform(dtpart,nelem,nt,nbin) 84 | mmrgas = reform(mmrgas,nt,ngas) 85 | satliq = reform(satliq,nt,ngas) 86 | satice = reform(satice,nt,ngas) 87 | 88 | !p.multi = [0,1,4] 89 | loadct, 39 90 | 91 | ;Calculate the column mass, which should be conserved. 92 | mmrelem = fltarr(nt,nelem) 93 | mmrtotal = fltarr(nt) 94 | 95 | for ielem = 0, nelem-1 do begin 96 | for it = 0, nt-1 do begin 97 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 98 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 99 | endfor 100 | endfor 101 | 102 | mmr[where(mmr le 0.)] = !Values.F_NAN 103 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 104 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 105 | satliq[0,*] = !Values.F_NAN 106 | satice[0,*] = !Values.F_NAN 107 | 108 | for it = 0, nt-1 do begin 109 | plot, r[*], mmr[0,0,*], yrange=[1e-30, 10*max(mmrtotal)], $ 110 | title = 'time = '+string(time[it])+' seconds', $ 111 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=6, $ 112 | /XLOG, /YLOG, charsize=2.0 113 | 114 | ; Add a legend 115 | plots, [2,2.5], 1e-10, thick=3, lin=0, color=66 116 | plots, [2,2.5], 1e-15, thick=3, lin=0, color=96 117 | xyouts, 2.7, 1e-10, 'Ice', color=66 118 | xyouts, 2.7, 1e-15, 'Water Vapor', color=96 119 | 120 | for ielem = 0, nelem-1 do begin 121 | oplot, r[*], mmr[ielem,it,*], lin=ielem, thick=6, color=66 122 | endfor 123 | 124 | for igas = 0, ngas-1 do begin 125 | oplot, [min(r), max(r)], [mmrgas[it, igas], mmrgas[it, igas]], thick=6, color=96, lin=igas 126 | endfor 127 | 128 | 129 | ; Show particle temperature 130 | maxdtp = max(abs(dtpart)) 131 | plot, r[*], dtpart[0,0,0:NBIN-2], yrange=[-maxdtp, maxdtp], $ 132 | title = 'Particle Temperature', $ 133 | xtitle='Radius [um]', ytitle = 'dTparticle [K]', thick=6, $ 134 | /XLOG, charsize=2.0 135 | 136 | ; Add a legend 137 | plots, [.0002,.0003], .72 * maxdtp, thick=3, lin=0, color=66 138 | xyouts, .00035, .7 * maxdtp, 'Ice', color=66 139 | 140 | for ielem = 0, nelem-1 do begin 141 | oplot, r[*], dtpart[ielem,it,0:NBIN-2], lin=ielem, thick=6, color=66 142 | endfor 143 | 144 | 145 | ; Show the mmr evolution. 146 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=6, $ 147 | title = 'Total mmr evolution', charsize=2.0, $ 148 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 149 | 150 | ; Add a legend 151 | plots, [2,2.5], 5.25e-6, thick=3, lin=0, color=66 152 | plots, [4,4.5], 5.25e-6, thick=3, lin=0, color=96 153 | plots, [9,9.5], 5.25e-6, thick=3, lin=0, color=26 154 | xyouts, 2.7, 5.e-6, 'Ice', color=66 155 | xyouts, 4.7, 5.e-6, 'Water Vapor', color=96 156 | xyouts, 9.7, 5.e-6, 'Total Water', color=26 157 | 158 | for ielem = 0, nelem-1 do begin 159 | oplot, mmrelem[*,ielem], thick=6, lin=ielem 160 | endfor 161 | for igas = 0, ngas-1 do begin 162 | oplot, mmrgas[*,igas], thick=6, lin=igas 163 | endfor 164 | 165 | oplot, mmrtotal[0:it], thick=6, color=26 166 | 167 | for ielem = 0, nelem-1 do begin 168 | oplot, mmrelem[0:it,ielem], thick=6, color=66, lin=ielem 169 | endfor 170 | 171 | for igas = 0, ngas-1 do begin 172 | oplot, mmrgas[0:it, igas], thick=6, color=96, lin=igas 173 | endfor 174 | 175 | ; Show the saturation evolution. 176 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=6, $ 177 | title = 'Gas Saturation Ratio', $ 178 | yrange=[0, 10], charsize=2.0 179 | 180 | ; Add a legend 181 | plots, [2,2.5], 8, thick=3, lin=0, color=66 182 | plots, [2,2.5], 6, thick=3, lin=0, color=196 183 | xyouts, 2.7, 7.75, 'Sat Ice', color=66 184 | xyouts, 2.7, 5.75, 'Sat Liq', color=196 185 | 186 | oplot, [0, nt], [1., 1.], thick=3 187 | 188 | for igas = 0, ngas-1 do begin 189 | oplot, satliq[*,igas], thick=6, lin=igas 190 | oplot, satice[*,igas], thick=6, lin=igas 191 | endfor 192 | 193 | for igas = 0, ngas-1 do begin 194 | oplot, satliq[0:it, igas], thick=6, color=196, lin=igas 195 | oplot, satice[0:it, igas], thick=6, color=66, lin=igas 196 | endfor 197 | 198 | wait, 15. / nt 199 | endfor 200 | 201 | end 202 | -------------------------------------------------------------------------------- /tests/read_growintest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_growintest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | mmrgas_ = fltarr(ngas) 23 | satliq_ = fltarr(ngas) 24 | satice_ = fltarr(ngas) 25 | 26 | data = fltarr(3) 27 | datag = fltarr(4) 28 | 29 | t_ = 0. 30 | nsubstep_ = 0 31 | nretry_ = 0 32 | 33 | nt = 0 34 | while(not(eof(lun))) do begin 35 | readf, lun, t1 36 | 37 | readf, lun, nsubstep_, nretry_, t_ 38 | 39 | for ielem = 0, nelem-1 do begin 40 | for ibin = 0, nbin-1 do begin 41 | readf, lun, data 42 | 43 | mmr_[ielem, ibin] = data[2] 44 | endfor 45 | endfor 46 | 47 | if (nt eq 0) then begin 48 | time = t1 49 | mmr = mmr_ 50 | nsubstep = nsubstep_ 51 | nretry = nretry_ 52 | t = t_ 53 | endif else begin 54 | time = [time,t1] 55 | mmr = [mmr,mmr_] 56 | nsubstep = [nsubstep,nsubstep_] 57 | nretry = [nretry,nretry_] 58 | t = [t,t_] 59 | endelse 60 | 61 | for igas = 0, ngas-1 do begin 62 | readf, lun, datag 63 | 64 | mmrgas_[igas] = datag[1] 65 | satliq_[igas] = datag[2] 66 | satice_[igas] = datag[3] 67 | endfor 68 | 69 | if (nt eq 0) then begin 70 | mmrgas = mmrgas_ 71 | satliq = satliq_ 72 | satice = satice_ 73 | endif else begin 74 | mmrgas = [mmrgas,mmrgas_] 75 | satliq = [satliq,satliq_] 76 | satice = [satice,satice_] 77 | endelse 78 | 79 | nt = nt+1 80 | endwhile 81 | 82 | free_lun, lun 83 | 84 | mmr = reform(mmr,nelem,nt,nbin) 85 | mmrgas = reform(mmrgas,nt,ngas) 86 | satliq = reform(satliq,nt,ngas) 87 | satice = reform(satice,nt,ngas) 88 | 89 | nsubstep[0] = !values.f_nan 90 | nretry[0] = !values.f_nan 91 | 92 | 93 | !p.multi = [0,2,3] 94 | loadct, 39 95 | 96 | ;Calculate the column mass, which should be conserved. 97 | mmrelem = fltarr(nt,nelem) 98 | mmrtotal = fltarr(nt) 99 | 100 | for ielem = 0, nelem-1 do begin 101 | for it = 0, nt-1 do begin 102 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 103 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 104 | endfor 105 | endfor 106 | 107 | mmr[where(mmr le 0.)] = !Values.F_NAN 108 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 109 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 110 | satliq[0,*] = !Values.F_NAN 111 | satice[0,*] = !Values.F_NAN 112 | 113 | for it = 0, nt-1 do begin 114 | plot, r[*], mmr[0,0,*], yrange=[1e-30, 10*max(mmrtotal)], $ 115 | title = 'time = '+string(time[it])+' seconds', $ 116 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=6, $ 117 | /XLOG, /YLOG, charsize=2.0 118 | 119 | ; Add a legend 120 | plots, [60,62], 1e-10, thick=3, lin=0, color=66 121 | plots, [60,62], 1e-5, thick=3, lin=0, color=96 122 | xyouts, 63, 1e-10, 'Ice', color=66 123 | xyouts, 63, 1e-5, 'Water Vapor', color=96 124 | 125 | for ielem = 0, nelem-1 do begin 126 | oplot, r[*], mmr[ielem,it,*], lin=ielem, thick=6, color=66 127 | endfor 128 | 129 | for igas = 0, ngas-1 do begin 130 | oplot, [min(r), max(r)], [mmrgas[it, igas], mmrgas[it, igas]], thick=6, color=96, lin=igas 131 | endfor 132 | 133 | ; Show the mmr evolution. 134 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=6, $ 135 | title = 'Total mmr evolution', charsize=2.0, $ 136 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 137 | 138 | ; Add a legend 139 | plots, [.25,.5], 5.5e-6, thick=3, lin=0, color=66 140 | plots, [1.5,1.75], 5.5e-6, thick=3, lin=0, color=96 141 | plots, [3.25,3.5], 5.5e-6, thick=3, lin=0, color=26 142 | xyouts, .75, 5.25e-6, 'Ice', color=66 143 | xyouts, 2., 5.25e-6, 'Water Vapor', color=96 144 | xyouts, 3.75, 5.25e-6, 'Total Water', color=26 145 | 146 | 147 | for ielem = 0, nelem-1 do begin 148 | oplot, mmrelem[*,ielem], thick=6, lin=ielem 149 | endfor 150 | for igas = 0, ngas-1 do begin 151 | oplot, mmrgas[*,igas], thick=6, lin=igas 152 | endfor 153 | 154 | oplot, mmrtotal[0:it], thick=6, color=26 155 | 156 | for ielem = 0, nelem-1 do begin 157 | oplot, mmrelem[0:it,ielem], thick=6, color=66, lin=ielem 158 | endfor 159 | 160 | for igas = 0, ngas-1 do begin 161 | oplot, mmrgas[0:it, igas], thick=6, color=96, lin=igas 162 | endfor 163 | 164 | 165 | ; Show the saturation evolution. 166 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=6, $ 167 | title = 'Gas Saturation Ratio', $ 168 | yrange=[0, 2], charsize=2.0 169 | 170 | ; Add a legend 171 | plots, [1,1.25], 1.75, thick=3, lin=0, color=66 172 | plots, [3.5,3.75], 1.75, thick=3, lin=0, color=196 173 | xyouts, 1.5, 1.7, 'Sat Ice', color=66 174 | xyouts, 4, 1.7, 'Sat Liq', color=196 175 | 176 | oplot, [0, nt], [1., 1.], thick=3 177 | 178 | for igas = 0, ngas-1 do begin 179 | oplot, satliq[*,igas], thick=6, lin=igas 180 | oplot, satice[*,igas], thick=6, lin=igas 181 | endfor 182 | 183 | for igas = 0, ngas-1 do begin 184 | oplot, satliq[0:it, igas], thick=6, color=196, lin=igas 185 | oplot, satice[0:it, igas], thick=6, color=66, lin=igas 186 | endfor 187 | 188 | 189 | ; Show the temperature evolution. 190 | plot, t[*], xtitle = 'Time Step', ytitle = 'dT (K)', thick=6, $ 191 | title = 'Delta Temperature', $ 192 | yrange=[0., max(t)], charsize=2.0 193 | 194 | oplot, t[0:it], thick=6, lin=0, color=66 195 | 196 | 197 | 198 | ; Show the substepping evolution. 199 | plot, nsubstep[0:*], xtitle = 'Time Step', ytitle = 'Nsubsteps', thick=6, $ 200 | title = 'Number of Substeps', $ 201 | yrange=[0., 1.2*max(nsubstep)], charsize=2.0 202 | 203 | oplot, nsubstep[0:it], thick=6, lin=0, color=66 204 | 205 | ; Show the retry evolution. 206 | plot, nretry[0:*], xtitle = 'Time Step', ytitle = 'Nretry', thick=6, $ 207 | title = 'Number of Retries', $ 208 | charsize=2.0 209 | 210 | oplot, nretry[0:it], thick=6, lin=0, color=66 211 | 212 | wait, 10. / nt 213 | endfor 214 | 215 | end 216 | -------------------------------------------------------------------------------- /tests/read_growsubtest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_growsubtest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | mmrgas_ = fltarr(ngas) 23 | satliq_ = fltarr(ngas) 24 | satice_ = fltarr(ngas) 25 | 26 | data = fltarr(3) 27 | datag = fltarr(4) 28 | 29 | t_ = 0. 30 | nsubstep_ = 0 31 | nretry_ = 0 32 | 33 | nt = 0 34 | while(not(eof(lun))) do begin 35 | readf, lun, t1 36 | 37 | readf, lun, nsubstep_, nretry_, t_ 38 | 39 | for ielem = 0, nelem-1 do begin 40 | for ibin = 0, nbin-1 do begin 41 | readf, lun, data 42 | 43 | mmr_[ielem, ibin] = data[2] 44 | endfor 45 | endfor 46 | 47 | if (nt eq 0) then begin 48 | time = t1 49 | mmr = mmr_ 50 | nsubstep = nsubstep_ 51 | nretry = nretry_ 52 | t = t_ 53 | endif else begin 54 | time = [time,t1] 55 | mmr = [mmr,mmr_] 56 | nsubstep = [nsubstep,nsubstep_] 57 | nretry = [nretry,nretry_] 58 | t = [t,t_] 59 | endelse 60 | 61 | for igas = 0, ngas-1 do begin 62 | readf, lun, datag 63 | 64 | mmrgas_[igas] = datag[1] 65 | satliq_[igas] = datag[2] 66 | satice_[igas] = datag[3] 67 | endfor 68 | 69 | if (nt eq 0) then begin 70 | mmrgas = mmrgas_ 71 | satliq = satliq_ 72 | satice = satice_ 73 | endif else begin 74 | mmrgas = [mmrgas,mmrgas_] 75 | satliq = [satliq,satliq_] 76 | satice = [satice,satice_] 77 | endelse 78 | 79 | nt = nt+1 80 | endwhile 81 | 82 | free_lun, lun 83 | 84 | mmr = reform(mmr,nelem,nt,nbin) 85 | mmrgas = reform(mmrgas,nt,ngas) 86 | satliq = reform(satliq,nt,ngas) 87 | satice = reform(satice,nt,ngas) 88 | 89 | nsubstep[0] = !values.f_nan 90 | nretry[0] = !values.f_nan 91 | 92 | 93 | !p.multi = [0,2,3] 94 | loadct, 39 95 | 96 | ;Calculate the column mass, which should be conserved. 97 | mmrelem = fltarr(nt,nelem) 98 | mmrtotal = fltarr(nt) 99 | 100 | for ielem = 0, nelem-1 do begin 101 | for it = 0, nt-1 do begin 102 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 103 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 104 | endfor 105 | endfor 106 | 107 | mmr[where(mmr le 0.)] = !Values.F_NAN 108 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 109 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 110 | satliq[0,*] = !Values.F_NAN 111 | satice[0,*] = !Values.F_NAN 112 | 113 | for it = 0, nt-1 do begin 114 | plot, r[*], mmr[0,0,*], yrange=[1e-30, 10*max(mmrtotal)], $ 115 | title = 'time = '+string(time[it])+' seconds', $ 116 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=6, $ 117 | /XLOG, /YLOG, charsize=2.0 118 | 119 | ; Add a legend 120 | plots, [60,62], 1e-10, thick=3, lin=0, color=66 121 | plots, [60,62], 1e-5, thick=3, lin=0, color=96 122 | xyouts, 63, 1e-10, 'Ice', color=66 123 | xyouts, 63, 1e-5, 'Water Vapor', color=96 124 | 125 | for ielem = 0, nelem-1 do begin 126 | oplot, r[*], mmr[ielem,it,*], lin=ielem, thick=6, color=66 127 | endfor 128 | 129 | for igas = 0, ngas-1 do begin 130 | oplot, [min(r), max(r)], [mmrgas[it, igas], mmrgas[it, igas]], thick=6, color=96, lin=igas 131 | endfor 132 | 133 | ; Show the mmr evolution. 134 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=6, $ 135 | title = 'Total mmr evolution', charsize=2.0, $ 136 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 137 | 138 | ; Add a legend 139 | plots, [.25,.5], 5.5e-6, thick=3, lin=0, color=66 140 | plots, [1.5,1.75], 5.5e-6, thick=3, lin=0, color=96 141 | plots, [3.25,3.5], 5.5e-6, thick=3, lin=0, color=26 142 | xyouts, .75, 5.25e-6, 'Ice', color=66 143 | xyouts, 2., 5.25e-6, 'Water Vapor', color=96 144 | xyouts, 3.75, 5.25e-6, 'Total Water', color=26 145 | 146 | 147 | for ielem = 0, nelem-1 do begin 148 | oplot, mmrelem[*,ielem], thick=6, lin=ielem 149 | endfor 150 | for igas = 0, ngas-1 do begin 151 | oplot, mmrgas[*,igas], thick=6, lin=igas 152 | endfor 153 | 154 | oplot, mmrtotal[0:it], thick=6, color=26 155 | 156 | for ielem = 0, nelem-1 do begin 157 | oplot, mmrelem[0:it,ielem], thick=6, color=66, lin=ielem 158 | endfor 159 | 160 | for igas = 0, ngas-1 do begin 161 | oplot, mmrgas[0:it, igas], thick=6, color=96, lin=igas 162 | endfor 163 | 164 | 165 | ; Show the saturation evolution. 166 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=6, $ 167 | title = 'Gas Saturation Ratio', $ 168 | yrange=[0, 2], charsize=2.0 169 | 170 | ; Add a legend 171 | plots, [1,1.25], 1.75, thick=3, lin=0, color=66 172 | plots, [3.5,3.75], 1.75, thick=3, lin=0, color=196 173 | xyouts, 1.5, 1.7, 'Sat Ice', color=66 174 | xyouts, 4, 1.7, 'Sat Liq', color=196 175 | 176 | oplot, [0, nt], [1., 1.], thick=3 177 | 178 | for igas = 0, ngas-1 do begin 179 | oplot, satliq[*,igas], thick=6, lin=igas 180 | oplot, satice[*,igas], thick=6, lin=igas 181 | endfor 182 | 183 | for igas = 0, ngas-1 do begin 184 | oplot, satliq[0:it, igas], thick=6, color=196, lin=igas 185 | oplot, satice[0:it, igas], thick=6, color=66, lin=igas 186 | endfor 187 | 188 | 189 | ; Show the temperature evolution. 190 | plot, t[*], xtitle = 'Time Step', ytitle = 'dT (K)', thick=6, $ 191 | title = 'Delta Temperature', $ 192 | yrange=[0., max(t)], charsize=2.0 193 | 194 | oplot, t[0:it], thick=6, lin=0, color=66 195 | 196 | 197 | 198 | ; Show the substepping evolution. 199 | plot, nsubstep[0:*], xtitle = 'Time Step', ytitle = 'Nsubsteps', thick=6, $ 200 | title = 'Number of Substeps', $ 201 | yrange=[0., 1.2*max(nsubstep)], charsize=2.0 202 | 203 | oplot, nsubstep[0:it], thick=6, lin=0, color=66 204 | 205 | ; Show the retry evolution. 206 | plot, nretry[0:*], xtitle = 'Time Step', ytitle = 'Nretry', thick=6, $ 207 | title = 'Number of Retries', $ 208 | charsize=2.0 209 | 210 | oplot, nretry[0:it], thick=6, lin=0, color=66 211 | 212 | wait, 10. / nt 213 | endfor 214 | 215 | end 216 | -------------------------------------------------------------------------------- /tests/read_nuc2test.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_nuc2test.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | mmrgas_ = fltarr(ngas) 23 | satliq_ = fltarr(ngas) 24 | satice_ = fltarr(ngas) 25 | 26 | data = fltarr(3) 27 | datag = fltarr(4) 28 | 29 | nt = 0 30 | while(not(eof(lun))) do begin 31 | readf, lun, t1 32 | for ielem = 0, nelem-1 do begin 33 | for ibin = 0, nbin-1 do begin 34 | readf, lun, data 35 | 36 | mmr_[ielem, ibin] = data[2] 37 | endfor 38 | endfor 39 | 40 | if (nt eq 0) then begin 41 | time = t1 42 | mmr = mmr_ 43 | endif else begin 44 | time = [time,t1] 45 | mmr = [mmr,mmr_] 46 | endelse 47 | 48 | for igas = 0, ngas-1 do begin 49 | readf, lun, datag 50 | 51 | mmrgas_[igas] = datag[1] 52 | satliq_[igas] = datag[2] 53 | satice_[igas] = datag[3] 54 | endfor 55 | 56 | if (nt eq 0) then begin 57 | mmrgas = mmrgas_ 58 | satliq = satliq_ 59 | satice = satice_ 60 | endif else begin 61 | mmrgas = [mmrgas,mmrgas_] 62 | satliq = [satliq,satliq_] 63 | satice = [satice,satice_] 64 | endelse 65 | 66 | nt = nt+1 67 | endwhile 68 | 69 | free_lun, lun 70 | 71 | mmr = reform(mmr,nelem,nt,nbin) 72 | mmrgas = reform(mmrgas,nt,ngas) 73 | satliq = reform(satliq,nt,ngas) 74 | satice = reform(satice,nt,ngas) 75 | 76 | 77 | !p.multi = [0,1,4] 78 | loadct, 39 79 | 80 | ;Calculate the column mass, which should be conserved. 81 | mmrelem = fltarr(nt,nelem) 82 | mmrtotal = fltarr(nt) 83 | 84 | for ielem = 0, nelem-1 do begin 85 | for it = 0, nt-1 do begin 86 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 87 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 88 | endfor 89 | endfor 90 | 91 | mmr[where(mmr le 0.)] = !Values.F_NAN 92 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 93 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 94 | satliq[0,*] = !Values.F_NAN 95 | satice[0,*] = !Values.F_NAN 96 | 97 | for it = 0, nt-1 do begin 98 | plot, r[0,*]*1000., mmr[0,0,*], yrange=[1e-20, 1e-10], xrange=[min(r[0,*])*1000., max(r[0,*])*1000.], $ 99 | title = 'Sulfate, time = '+string(time[it])+' seconds', $ 100 | xtitle='Radius [nm]', ytitle = 'MMR [kg/kg]', thick=4, $ 101 | /XLOG, /YLOG, charsize=2.0 102 | 103 | ; Add a legend 104 | ; plots, [1.5e-10,1.75e-10], 4.2, thick=3, color=66, lin=0 105 | ; plots, [1.5e-10,1.75e-10], 2.7, thick=3, color=66, lin=1 106 | ; plots, [1.5e-10,1.75e-10], 1.2, thick=3, color=66, lin=2 107 | ; xyouts, 1.8e-10, 4.2, 'None', color=66 108 | ; xyouts, 1.8e-10, 2.7, 'Fitzgerald', color=66 109 | ; xyouts, 1.8e-10, 1.2, 'Gerber', color=66 110 | 111 | oplot, r[0,*]*1000., mmr[0,it,*], thick=4, color=66 112 | 113 | plot, r[1,*], mmr[1,0,*], yrange=[1e-15, 1e-5], xrange=[min(r[1,*]), max(r[1,*])], $ 114 | title = 'H2O and Ice', $ 115 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=4, $ 116 | /XLOG, /YLOG, charsize=2.0 117 | 118 | for ielem = 1, nelem-1 do begin 119 | oplot, r[1,*], mmr[ielem,it,*], lin=ielem, thick=4, color=66 120 | endfor 121 | 122 | for igas = 0, ngas-1 do begin 123 | oplot, [min(r[1,*]), max(r[1,*])], [mmrgas[it, igas], mmrgas[it, igas]], thick=4, color=96, lin=igas 124 | endfor 125 | 126 | ; Show the mmr evolution. 127 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=4, $ 128 | title = 'Total mmr evolution', charsize=2.0, $ 129 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 130 | 131 | for ielem = 0, nelem-1 do begin 132 | oplot, mmrelem[*,ielem], thick=4, lin=ielem 133 | endfor 134 | 135 | for igas = 0, ngas-1 do begin 136 | oplot, mmrgas[*,igas], thick=4, lin=igas 137 | endfor 138 | 139 | oplot, mmrtotal[0:it], thick=4, color=26 140 | 141 | for ielem = 0, nelem-1 do begin 142 | oplot, mmrelem[0:it,ielem], thick=4, color=66, lin=ielem 143 | endfor 144 | 145 | for igas = 0, ngas-1 do begin 146 | oplot, mmrgas[0:it, igas], thick=4, color=96, lin=igas 147 | endfor 148 | 149 | ; Show the saturation evolution. 150 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=4, $ 151 | title = 'Gas Saturation Ratio', $ 152 | yrange=[0, 2], charsize=2.0 153 | 154 | oplot, [0, nt], [1., 1.], thick=2 155 | 156 | for igas = 0, ngas-1 do begin 157 | oplot, satliq[*,igas], thick=4, lin=igas 158 | oplot, satice[*,igas], thick=4, lin=igas 159 | endfor 160 | 161 | for igas = 0, ngas-1 do begin 162 | oplot, satliq[0:it, igas], thick=4, color=196, lin=igas 163 | oplot, satice[0:it, igas], thick=4, color=66, lin=igas 164 | endfor 165 | 166 | wait, 20. / nt 167 | endfor 168 | 169 | ; plot, q[*,0,0], z[*], yrange=[0,15], xrange=[0,2.e-10], $ 170 | ; title = 'Falling History', $ 171 | ; xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 172 | ; oplot, [0,2.5e-10], [8,8], thick=1, lin=1 173 | ; xyouts, 1.5e-10, 9.2, 't = 0 sec' 174 | 175 | ; Add a legend 176 | ; plots, [1.5e-10,1.75e-10], 4.2, thick=3, lin=0 177 | ; plots, [1.5e-10,1.75e-10], 2.7, thick=3, lin=1 178 | ; plots, [1.5e-10,1.75e-10], 1.2, thick=3, lin=2 179 | ; xyouts, 1.8e-10, 4.2, 'None' 180 | ; xyouts, 1.8e-10, 2.7, 'Fitzgerald' 181 | ; xyouts, 1.8e-10, 1.2, 'Gerber' 182 | 183 | ; it = 200 184 | ; for ielem = 0, nelem-1 do begin 185 | ; oplot, q[*,it,ielem], z[*], color=86, thick=3, line=ielem 186 | ; endfor 187 | ; oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 188 | ; xyouts, 1.5e-10, 7.7, 't = 200000 sec', color=86 189 | 190 | ; it = 400 191 | ; for ielem = 0, nelem-1 do begin 192 | ; oplot, q[*,it,ielem], z[*], color=126, thick=3, line=ielem 193 | ; endfor 194 | ; oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 195 | ; xyouts, 1.5e-10, 6.2, 't = 400000 sec', color=126 196 | 197 | ; plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 198 | ; title = 'Total mass evolution' 199 | ; for ielem = 0, nelem-1 do begin 200 | ; oplot, mass[ielem,*], thick=6, color=66, lin=ielem 201 | ; endfor 202 | 203 | end 204 | -------------------------------------------------------------------------------- /tests/read_nuctest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_nuctest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | mmr_ = fltarr(nelem, nbin) 22 | mmrgas_ = fltarr(ngas) 23 | satliq_ = fltarr(ngas) 24 | satice_ = fltarr(ngas) 25 | 26 | data = fltarr(3) 27 | datag = fltarr(4) 28 | 29 | nt = 0 30 | while(not(eof(lun))) do begin 31 | readf, lun, t1 32 | for ielem = 0, nelem-1 do begin 33 | for ibin = 0, nbin-1 do begin 34 | readf, lun, data 35 | 36 | mmr_[ielem, ibin] = data[2] 37 | endfor 38 | endfor 39 | 40 | if (nt eq 0) then begin 41 | time = t1 42 | mmr = mmr_ 43 | endif else begin 44 | time = [time,t1] 45 | mmr = [mmr,mmr_] 46 | endelse 47 | 48 | for igas = 0, ngas-1 do begin 49 | readf, lun, datag 50 | 51 | mmrgas_[igas] = datag[1] 52 | satliq_[igas] = datag[2] 53 | satice_[igas] = datag[3] 54 | endfor 55 | 56 | if (nt eq 0) then begin 57 | mmrgas = mmrgas_ 58 | satliq = satliq_ 59 | satice = satice_ 60 | endif else begin 61 | mmrgas = [mmrgas,mmrgas_] 62 | satliq = [satliq,satliq_] 63 | satice = [satice,satice_] 64 | endelse 65 | 66 | nt = nt+1 67 | endwhile 68 | 69 | free_lun, lun 70 | 71 | mmr = reform(mmr,nelem,nt,nbin) 72 | mmrgas = reform(mmrgas,nt,ngas) 73 | satliq = reform(satliq,nt,ngas) 74 | satice = reform(satice,nt,ngas) 75 | 76 | 77 | !p.multi = [0,1,4] 78 | loadct, 39 79 | 80 | ;Calculate the column mass, which should be conserved. 81 | mmrelem = fltarr(nt,nelem) 82 | mmrtotal = fltarr(nt) 83 | 84 | for ielem = 0, nelem-1 do begin 85 | for it = 0, nt-1 do begin 86 | mmrelem[it,ielem] = total(mmr[ielem,it,*]) 87 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 88 | endfor 89 | endfor 90 | 91 | mmr[where(mmr le 0.)] = !Values.F_NAN 92 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 93 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 94 | satliq[0,*] = !Values.F_NAN 95 | satice[0,*] = !Values.F_NAN 96 | 97 | for it = 0, nt-1 do begin 98 | plot, r[0,*]*1000., mmr[0,0,*], yrange=[1e-20, 1e-10], xrange=[min(r[0,*])*1000., max(r[0,*])*1000.], $ 99 | title = 'Sulfate, time = '+string(time[it])+' seconds', $ 100 | xtitle='Radius [nm]', ytitle = 'MMR [kg/kg]', thick=4, $ 101 | /XLOG, /YLOG, charsize=2.0 102 | 103 | ; Add a legend 104 | ; plots, [1.5e-10,1.75e-10], 4.2, thick=3, color=66, lin=0 105 | ; plots, [1.5e-10,1.75e-10], 2.7, thick=3, color=66, lin=1 106 | ; plots, [1.5e-10,1.75e-10], 1.2, thick=3, color=66, lin=2 107 | ; xyouts, 1.8e-10, 4.2, 'None', color=66 108 | ; xyouts, 1.8e-10, 2.7, 'Fitzgerald', color=66 109 | ; xyouts, 1.8e-10, 1.2, 'Gerber', color=66 110 | 111 | oplot, r[0,*]*1000., mmr[0,it,*], thick=4, color=66 112 | 113 | plot, r[1,*], mmr[1,0,*], yrange=[1e-15, 1e-5], xrange=[min(r[1,*]), max(r[1,*])], $ 114 | title = 'H2O and Ice', $ 115 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=4, $ 116 | /XLOG, /YLOG, charsize=2.0 117 | 118 | for ielem = 1, nelem-1 do begin 119 | oplot, r[1,*], mmr[ielem,it,*], lin=ielem, thick=4, color=66 120 | endfor 121 | 122 | for igas = 0, ngas-1 do begin 123 | oplot, [min(r[1,*]), max(r[1,*])], [mmrgas[it, igas], mmrgas[it, igas]], thick=4, color=96, lin=igas 124 | endfor 125 | 126 | ; Show the mmr evolution. 127 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=4, $ 128 | title = 'Total mmr evolution', charsize=2.0, $ 129 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 130 | 131 | for ielem = 0, nelem-1 do begin 132 | oplot, mmrelem[*,ielem], thick=4, lin=ielem 133 | endfor 134 | 135 | for igas = 0, ngas-1 do begin 136 | oplot, mmrgas[*,igas], thick=4, lin=igas 137 | endfor 138 | 139 | oplot, mmrtotal[0:it], thick=4, color=26 140 | 141 | for ielem = 0, nelem-1 do begin 142 | oplot, mmrelem[0:it,ielem], thick=4, color=66, lin=ielem 143 | endfor 144 | 145 | for igas = 0, ngas-1 do begin 146 | oplot, mmrgas[0:it, igas], thick=4, color=96, lin=igas 147 | endfor 148 | 149 | ; Show the saturation evolution. 150 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=4, $ 151 | title = 'Gas Saturation Ratio', $ 152 | yrange=[0, 2], charsize=2.0 153 | 154 | oplot, [0, nt], [1., 1.], thick=2 155 | 156 | for igas = 0, ngas-1 do begin 157 | oplot, satliq[*,igas], thick=4, lin=igas 158 | oplot, satice[*,igas], thick=4, lin=igas 159 | endfor 160 | 161 | for igas = 0, ngas-1 do begin 162 | oplot, satliq[0:it, igas], thick=4, color=196, lin=igas 163 | oplot, satice[0:it, igas], thick=4, color=66, lin=igas 164 | endfor 165 | 166 | wait, 20. / nt 167 | endfor 168 | 169 | ; plot, q[*,0,0], z[*], yrange=[0,15], xrange=[0,2.e-10], $ 170 | ; title = 'Falling History', $ 171 | ; xtitle='Particle Concentration [g cm-3]', ytitle = 'Altitude [km]', thick=3 172 | ; oplot, [0,2.5e-10], [8,8], thick=1, lin=1 173 | ; xyouts, 1.5e-10, 9.2, 't = 0 sec' 174 | 175 | ; Add a legend 176 | ; plots, [1.5e-10,1.75e-10], 4.2, thick=3, lin=0 177 | ; plots, [1.5e-10,1.75e-10], 2.7, thick=3, lin=1 178 | ; plots, [1.5e-10,1.75e-10], 1.2, thick=3, lin=2 179 | ; xyouts, 1.8e-10, 4.2, 'None' 180 | ; xyouts, 1.8e-10, 2.7, 'Fitzgerald' 181 | ; xyouts, 1.8e-10, 1.2, 'Gerber' 182 | 183 | ; it = 200 184 | ; for ielem = 0, nelem-1 do begin 185 | ; oplot, q[*,it,ielem], z[*], color=86, thick=3, line=ielem 186 | ; endfor 187 | ; oplot, [0,2.5e-10], [4,4], color=86, thick=1, lin=1 188 | ; xyouts, 1.5e-10, 7.7, 't = 200000 sec', color=86 189 | 190 | ; it = 400 191 | ; for ielem = 0, nelem-1 do begin 192 | ; oplot, q[*,it,ielem], z[*], color=126, thick=3, line=ielem 193 | ; endfor 194 | ; oplot, [0,2.5e-10], [0,0], color=126, thick=1, lin=1 195 | ; xyouts, 1.5e-10, 6.2, 't = 400000 sec', color=126 196 | 197 | ; plot, mass[0,*], xtitle = 'Time Step', ytitle = 'Column Mass [g cm-2]', thick=6, $ 198 | ; title = 'Total mass evolution' 199 | ; for ielem = 0, nelem-1 do begin 200 | ; oplot, mass[ielem,*], thick=6, color=66, lin=ielem 201 | ; endfor 202 | 203 | end 204 | -------------------------------------------------------------------------------- /tests/read_growclrtest.pro: -------------------------------------------------------------------------------- 1 | openr, lun, 'carma_growclrtest.txt', /get_lun 2 | 3 | ; Read in the sizes. 4 | readf, lun, ngroup, nelem, nbin, ngas 5 | 6 | r = fltarr(ngroup, nbin) 7 | rmass = fltarr(ngroup, nbin) 8 | 9 | data = fltarr(4) 10 | 11 | for igroup = 0, ngroup-1 do begin 12 | for ibin = 0, nbin-1 do begin 13 | readf, lun, data 14 | 15 | r[igroup, ibin] = data[2] 16 | rmass[igroup, ibin] = data[3] 17 | endfor 18 | endfor 19 | 20 | ; Read in the particles for each time step. 21 | ; mmr_ = fltarr(nelem, nbin) 22 | mmr_ = fltarr(nbin, nelem) 23 | mmrgas_ = fltarr(ngas) 24 | satliq_ = fltarr(ngas) 25 | satice_ = fltarr(ngas) 26 | 27 | data = fltarr(3) 28 | datag = fltarr(4) 29 | 30 | t_ = 0. 31 | nsubstep_ = 0 32 | nretry_ = 0 33 | 34 | nt = 0 35 | while(not(eof(lun))) do begin 36 | readf, lun, t1 37 | 38 | readf, lun, nsubstep_, nretry_, t_ 39 | 40 | for ielem = 0, nelem-1 do begin 41 | for ibin = 0, nbin-1 do begin 42 | readf, lun, data 43 | 44 | mmr_[ibin, ielem] = data[2] 45 | endfor 46 | endfor 47 | 48 | if (nt eq 0) then begin 49 | time = t1 50 | mmr = mmr_ 51 | nsubstep = nsubstep_ 52 | nretry = nretry_ 53 | t = t_ 54 | endif else begin 55 | time = [time,t1] 56 | mmr = [mmr,mmr_] 57 | nsubstep = [nsubstep,nsubstep_] 58 | nretry = [nretry,nretry_] 59 | t = [t,t_] 60 | endelse 61 | 62 | for igas = 0, ngas-1 do begin 63 | readf, lun, datag 64 | 65 | mmrgas_[igas] = datag[1] 66 | satliq_[igas] = datag[2] 67 | satice_[igas] = datag[3] 68 | endfor 69 | 70 | if (nt eq 0) then begin 71 | mmrgas = mmrgas_ 72 | satliq = satliq_ 73 | satice = satice_ 74 | endif else begin 75 | mmrgas = [mmrgas,mmrgas_] 76 | satliq = [satliq,satliq_] 77 | satice = [satice,satice_] 78 | endelse 79 | 80 | nt = nt+1 81 | endwhile 82 | 83 | free_lun, lun 84 | 85 | mmr = reform(mmr,nbin,nt,nelem) 86 | mmrgas = reform(mmrgas,nt,ngas) 87 | satliq = reform(satliq,nt,ngas) 88 | satice = reform(satice,nt,ngas) 89 | 90 | nsubstep[0] = !values.f_nan 91 | nretry[0] = !values.f_nan 92 | 93 | 94 | !p.multi = [0,2,3] 95 | loadct, 39 96 | 97 | ;Calculate the column mass, which should be conserved. 98 | mmrelem = fltarr(nt,nelem) 99 | mmrtotal = fltarr(nt) 100 | 101 | for it = 0, nt-1 do begin 102 | for ielem = 0, nelem-1 do begin 103 | mmrelem[it,ielem] = total(mmr[*,it,ielem]) 104 | endfor 105 | mmrtotal[it] = total(mmrelem[it,*]) + total(mmrgas[it, *]) 106 | endfor 107 | 108 | mmr[where(mmr le 0.)] = !Values.F_NAN 109 | ; mmrelem[where(mmrelem le 0.)] = !Values.F_NAN 110 | ; mmrtotal[where(mmrtotal le 0.)] = !Values.F_NAN 111 | satliq[0,*] = !Values.F_NAN 112 | satice[0,*] = !Values.F_NAN 113 | 114 | for it = 0, nt-1 do begin 115 | plot, r[*], mmr[*,0,0], yrange=[1e-30, 10*max(mmrtotal)], $ 116 | title = 'time = '+string(time[it])+' seconds', $ 117 | xtitle='Radius [um]', ytitle = 'MMR [kg/kg]', thick=6, $ 118 | /XLOG, /YLOG, charsize=2.0 119 | 120 | ; Add a legend 121 | plots, [60,62], 1e-10, thick=3, lin=0, color=66 122 | plots, [60,62], 1e-5, thick=3, lin=0, color=96 123 | xyouts, 63, 1e-10, 'Ice', color=66 124 | xyouts, 63, 1e-5, 'Water Vapor', color=96 125 | 126 | for ielem = 0, nelem-1 do begin 127 | oplot, r[ielem,*], mmr[*,it,ielem], lin=ielem, thick=6, color=66 128 | endfor 129 | 130 | for igas = 0, ngas-1 do begin 131 | oplot, [min(r), max(r)], [mmrgas[it, igas], mmrgas[it, igas]], thick=6, color=96, lin=igas 132 | endfor 133 | 134 | ; Show the mmr evolution. 135 | plot, mmrtotal[*], xtitle = 'Time Step', ytitle = 'mmr [kg/kg]', thick=6, $ 136 | title = 'Total mmr evolution', charsize=2.0, $ 137 | yrange=[min([min(mmrtotal), min(mmrgas), min(mmrelem)]), max([max(mmrtotal), 1.5*max(mmrgas), max(mmrelem)])] 138 | 139 | ; Add a legend 140 | plots, [.25,.5], 5.5e-6, thick=3, lin=0, color=66 141 | plots, [1.5,1.75], 5.5e-6, thick=3, lin=0, color=96 142 | plots, [3.25,3.5], 5.5e-6, thick=3, lin=0, color=26 143 | xyouts, .75, 5.25e-6, 'Ice', color=66 144 | xyouts, 2., 5.25e-6, 'Water Vapor', color=96 145 | xyouts, 3.75, 5.25e-6, 'Total Water', color=26 146 | 147 | 148 | for ielem = 0, nelem-1 do begin 149 | oplot, mmrelem[*,ielem], thick=6, lin=ielem 150 | endfor 151 | for igas = 0, ngas-1 do begin 152 | oplot, mmrgas[*,igas], thick=6, lin=igas 153 | endfor 154 | 155 | oplot, mmrtotal[0:it], thick=6, color=26 156 | 157 | for ielem = 0, nelem-1 do begin 158 | oplot, mmrelem[0:it,ielem], thick=6, color=66, lin=ielem 159 | endfor 160 | 161 | for igas = 0, ngas-1 do begin 162 | oplot, mmrgas[0:it, igas], thick=6, color=96, lin=igas 163 | endfor 164 | 165 | 166 | ; Show the saturation evolution. 167 | plot, satice[*], xtitle = 'Time Step', ytitle = 's', thick=6, $ 168 | title = 'Gas Saturation Ratio', $ 169 | yrange=[0, 2], charsize=2.0 170 | 171 | ; Add a legend 172 | plots, [1,1.25], 1.75, thick=3, lin=0, color=66 173 | plots, [3.5,3.75], 1.75, thick=3, lin=0, color=196 174 | xyouts, 1.5, 1.7, 'Sat Ice', color=66 175 | xyouts, 4, 1.7, 'Sat Liq', color=196 176 | 177 | oplot, [0, nt], [1., 1.], thick=3 178 | 179 | for igas = 0, ngas-1 do begin 180 | oplot, satliq[*,igas], thick=6, lin=igas 181 | oplot, satice[*,igas], thick=6, lin=igas 182 | endfor 183 | 184 | for igas = 0, ngas-1 do begin 185 | oplot, satliq[0:it, igas], thick=6, color=196, lin=igas 186 | oplot, satice[0:it, igas], thick=6, color=66, lin=igas 187 | endfor 188 | 189 | 190 | ; Show the temperature evolution. 191 | plot, t[*], xtitle = 'Time Step', ytitle = 'dT (K)', thick=6, $ 192 | title = 'Delta Temperature', $ 193 | yrange=[0., max(t)], charsize=2.0 194 | 195 | oplot, t[0:it], thick=6, lin=0, color=66 196 | 197 | 198 | 199 | ; Show the substepping evolution. 200 | plot, nsubstep[0:*], xtitle = 'Time Step', ytitle = 'Nsubsteps', thick=6, $ 201 | title = 'Number of Substeps', $ 202 | yrange=[0., 1.2*max(nsubstep)], charsize=2.0 203 | 204 | oplot, nsubstep[0:it], thick=6, lin=0, color=66 205 | 206 | ; Show the retry evolution. 207 | plot, nretry[0:*], xtitle = 'Time Step', ytitle = 'Nretry', thick=6, $ 208 | title = 'Number of Retries', $ 209 | charsize=2.0 210 | 211 | oplot, nretry[0:it], thick=6, lin=0, color=66 212 | 213 | wait, 10. / nt 214 | endfor 215 | 216 | end 217 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Community Aerosol and Radiation Model for Atmospheres (CARMA) 2 | [![License](https://img.shields.io/github/license/ESCOMP/CARMA.svg)](https://github.com/ESCOMP/CARMA/blob/main/LICENSE) 3 | [![ubuntu](https://github.com/ESCOMP/CARMA/actions/workflows/Ubuntu.yml/badge.svg)](https://github.com/ESCOMP/CARMA/actions/workflows/Ubuntu.yml) 4 | 5 | ### Getting the code 6 | 7 | ``` 8 | git clone --recursive https://github.com/ESCOMP/CARMA.git 9 | ``` 10 | 11 | This populates source/base with source code from https://github.com/ESCOMP/CARMA_base. 12 | 13 | ___ 14 | ## README 15 | 16 | This project contains files to build version 4.0 of the Community Aerosol and 17 | Radiation Model for Atmospheres (CARMA) that is based off of the 2.3 release, 18 | but has been ported to Fortran 90 and repackaged so that it can be used as a 19 | cloud and aerosol physics package embedded into GCMs. The project consists of 20 | 4 components that are each located in their own subdirectories: 21 | 22 | - bin : the F90doc documentation generation tool 23 | - doc : the change log and HTML based documentation 24 | - source : the CARMA microphysics layer 25 | - tests : the test routines & benchmark results 26 | 27 | Two script files have been provided to build and run the model or its 28 | components. To build carma and the test cases, issue the following command 29 | rom the root directory: 30 | ``` 31 | make-carma.csh 32 | ``` 33 | This will build all the files in a subdirectory called build/carma. 34 | Note: LAPACK external library is required for the CARMA base code 35 | (This avoids the used of the copied LU matrix solve routines from copyrighted source) 36 | 37 | To run a sample carma model, execute the following command from the root directory: 38 | ``` 39 | run-carma.csh 40 | ``` 41 | This will copy the CARMA.exe executable to the directory run/carma and then 42 | will execute it with all output going to the run/carma directory. The 43 | dependency hierarchy is set up in the make files, so rebuilding should only 44 | rebuild what is necessary. There are only two #defines that can be set in the 45 | makefile to control the build. One specifies the precision (SINGLE) and the other 46 | is used to build a version with extra debug information (DEBUG). The scripts can 47 | also be used to build individual executables. For example, to build and run the 48 | NUCTEST test routine and to have the run performed in a directory named nuctest 49 | (this part is optional) execute: 50 | ``` 51 | make-carma.csh NUCTEST.exe 52 | run-carma.csh NUCTEST.exe 53 | ``` 54 | NOTE: bash and ksh users will need to use export rather than setenv. 55 | 56 | Plotting routines have been created for each test in IDL. If you set CARMA_IDL 57 | to be the path to your copy of IDL, then IDL should be launched automatical, and 58 | the messages will indicate the program that you should run. On the Mac, you would 59 | set a path like: 60 | ``` 61 | setenv CARMA_IDL /Applications/itt/idl/idl80/bin/idl 62 | ``` 63 | After exectuing 64 | ``` 65 | run-carma.csh NUCTEST.exe 66 | ``` 67 | you should see an IDL prompt that looks like this: 68 | 69 | ``` 70 | ** Finished at Wed Jul 13 20:41:11 MDT 2011 ** 71 | 72 | Running the IDL analysis routine read_nuctest.pro 73 | To run the test, in IDL you need to type the command: .r read_nuctest.pro 74 | To exit IDL, type the command: exit 75 | 76 | IDL Version 8.0, Mac OS X (darwin x86_64 m64). (c) 2010, ITT Visual Information Solutions 77 | Installation number: 95183-2518. 78 | Licensed for use by: ACD:acd-license:Linux.FL 79 | 80 | IDL> 81 | ``` 82 | Type: 83 | ``` 84 | .r read_nuctest.pro 85 | ``` 86 | and you should get a plot generated showing the results of the test. 87 | 88 | 89 | Documentation of the code is generated automatically by the make scripts using 90 | the program f90doc, which is located in the bin directory. The generated 91 | documentation is stored as html files in the directory doc/f90doc. To start 92 | browsing the documentation, open the file doc/index.html. 93 | 94 | 95 | The model supports OPEN/MP, which will allow the model to use multiple 96 | processors if the model is called with multiple columns. You need to add 97 | a compiler directive to enable OPEN/MP (-openmp for ifort) and you need 98 | to specify the number of threads when you run. The run script uses the 99 | CARMA_THREADS flag to determine how many threads to allow during execution. 100 | The dault is 1 thread. To run with 4 threads issue the command 101 | ``` 102 | setenv CARMA_THREADS 4 103 | ``` 104 | before using the run script. 105 | 106 | Several test cases have been developed to show how the CARMA model 107 | can be used and to test that the model physics is performing correctly. The 108 | source code for these tests are located in the tests subdirectory. 109 | 110 | To run all of the tests interactively, use the command 111 | ``` 112 | run-all.csh 113 | ``` 114 | To run all of the tests in the background and compare the results to 115 | benchmark results, use the command 116 | ``` 117 | run-regress.csh 118 | ``` 119 | The benchmarks are stored in tests/bench and were created on a Mac 120 | using the Intel Fortran compiler. You may get slightly different 121 | results on other platforms or with other compilers. 122 | 123 | 124 | The entire project can be put into a tar file, using the command 125 | ``` 126 | make-carma.csh tar 127 | ``` 128 | This will create a tar file called CARMA.tar in the current build directory, 129 | which defaults to build/carma. NOTE: This tar file does not contain the 130 | contents of the build, doc or run directories since they are 131 | products of the make and run scripts. 132 | 133 | CARMA has a ChangeLog in the doc directory. It contains the revision history 134 | of CARMA. When changes are made, please prepend the ChangeLog with a 135 | description of the change based upon filling out the ChangeLog_template 136 | which is also stored in the doc directory. 137 | 138 | 139 | Chuck Bardeen, Pete Colarco and Jamie Smith 140 | Jul-2011 141 | 142 | ## CMake Build 143 | 144 | To build CARMA with CMake locally and run the tests: 145 | ``` 146 | git clone https://github.com/ESCOMP/CARMA.git 147 | cd CARMA 148 | mkdir build 149 | cd build 150 | cmake .. 151 | make 152 | make test 153 | ``` 154 | 155 | Note that the CMake tests only run the test configurations, but do not verify results. 156 | To include memory checking with Valgrind for the tests, add the `CARMA_ENABLE_MEMCHECK` 157 | flag to the cmake step: 158 | ``` 159 | cmake -D CARMA_ENABLE_MEMCHECK=ON .. 160 | ``` 161 | 162 | To exclude NetCDF as a dependency: 163 | ``` 164 | cmake -D CARMA_ENABLE_NETCDF=OFF .. 165 | ``` 166 | Note that this will disable some of the tests. 167 | 168 | ## Docker Build 169 | 170 | To build and run CARMA with Docker: 171 | ``` 172 | git clone https://github.com/ESCOMP/CARMA.git 173 | cd CARMA 174 | docker build -t carma . -f docker/Dockerfile 175 | docker run carma bash 176 | make test 177 | ``` 178 | 179 | Build args can be used to set CARMA build options 180 | | Build Arg | Values | 181 | |-----------|--------| 182 | | BUILD_TYPE | Release / Debug | 183 | | ENABLE_NETCDF | ON / OFF | 184 | | ENABLE_MEMCHECK | ON / OFF | 185 | 186 | To include the args modify the `docker build` step: 187 | ``` 188 | docker build -t carma . -f docker/Dockerfile --build-arg ENABLE_NETCDF=OFF --build-arg BUILD_TYPE=Debug 189 | ``` 190 | -------------------------------------------------------------------------------- /tests/bench/carma_growclrtest.txt: -------------------------------------------------------------------------------- 1 | 2 2 18 1 2 | 1 1 0.100E+01 0.390E-11 3 | 1 2 0.126E+01 0.779E-11 4 | 1 3 0.159E+01 0.156E-10 5 | 1 4 0.200E+01 0.312E-10 6 | 1 5 0.252E+01 0.623E-10 7 | 1 6 0.317E+01 0.125E-09 8 | 1 7 0.400E+01 0.249E-09 9 | 1 8 0.504E+01 0.499E-09 10 | 1 9 0.635E+01 0.997E-09 11 | 1 10 0.800E+01 0.199E-08 12 | 1 11 0.101E+02 0.399E-08 13 | 1 12 0.127E+02 0.798E-08 14 | 1 13 0.160E+02 0.160E-07 15 | 1 14 0.202E+02 0.319E-07 16 | 1 15 0.254E+02 0.638E-07 17 | 1 16 0.320E+02 0.128E-06 18 | 1 17 0.403E+02 0.255E-06 19 | 1 18 0.508E+02 0.511E-06 20 | 2 1 0.100E+01 0.390E-11 21 | 2 2 0.126E+01 0.779E-11 22 | 2 3 0.159E+01 0.156E-10 23 | 2 4 0.200E+01 0.312E-10 24 | 2 5 0.252E+01 0.623E-10 25 | 2 6 0.317E+01 0.125E-09 26 | 2 7 0.400E+01 0.249E-09 27 | 2 8 0.504E+01 0.499E-09 28 | 2 9 0.635E+01 0.997E-09 29 | 2 10 0.800E+01 0.199E-08 30 | 2 11 0.101E+02 0.399E-08 31 | 2 12 0.127E+02 0.798E-08 32 | 2 13 0.160E+02 0.160E-07 33 | 2 14 0.202E+02 0.319E-07 34 | 2 15 0.254E+02 0.638E-07 35 | 2 16 0.320E+02 0.128E-06 36 | 2 17 0.403E+02 0.255E-06 37 | 2 18 0.508E+02 0.511E-06 38 | 0 39 | 0 0 0.000E+00 40 | 1 1 0.118E-08 41 | 1 2 0.000E+00 42 | 1 3 0.000E+00 43 | 1 4 0.000E+00 44 | 1 5 0.000E+00 45 | 1 6 0.000E+00 46 | 1 7 0.000E+00 47 | 1 8 0.000E+00 48 | 1 9 0.000E+00 49 | 1 10 0.000E+00 50 | 1 11 0.000E+00 51 | 1 12 0.000E+00 52 | 1 13 0.000E+00 53 | 1 14 0.000E+00 54 | 1 15 0.000E+00 55 | 1 16 0.000E+00 56 | 1 17 0.000E+00 57 | 1 18 0.000E+00 58 | 2 1 0.118E-08 59 | 2 2 0.000E+00 60 | 2 3 0.000E+00 61 | 2 4 0.000E+00 62 | 2 5 0.000E+00 63 | 2 6 0.000E+00 64 | 2 7 0.000E+00 65 | 2 8 0.000E+00 66 | 2 9 0.000E+00 67 | 2 10 0.000E+00 68 | 2 11 0.000E+00 69 | 2 12 0.000E+00 70 | 2 13 0.000E+00 71 | 2 14 0.000E+00 72 | 2 15 0.000E+00 73 | 2 16 0.000E+00 74 | 2 17 0.000E+00 75 | 2 18 0.000E+00 76 | 1 0.350E-05 0.000E+00 0.000E+00 77 | 1000. 78 | 64 0 0.17823E-02 79 | 1 1 0.161E-23 80 | 1 2 0.801E-20 81 | 1 3 0.312E-17 82 | 1 4 0.508E-15 83 | 1 5 0.749E-13 84 | 1 6 0.101E-10 85 | 1 7 0.151E-08 86 | 1 8 0.379E-07 87 | 1 9 0.151E-06 88 | 1 10 0.131E-06 89 | 1 11 0.122E-07 90 | 1 12 0.609E-09 91 | 1 13 0.178E-10 92 | 1 14 0.314E-12 93 | 1 15 0.340E-14 94 | 1 16 0.230E-16 95 | 1 17 0.977E-19 96 | 1 18 0.104E-20 97 | 2 1 0.896E-24 98 | 2 2 0.699E-20 99 | 2 3 0.545E-17 100 | 2 4 0.773E-15 101 | 2 5 0.105E-12 102 | 2 6 0.163E-10 103 | 2 7 0.247E-08 104 | 2 8 0.437E-07 105 | 2 9 0.152E-06 106 | 2 10 0.101E-06 107 | 2 11 0.860E-08 108 | 2 12 0.398E-09 109 | 2 13 0.107E-10 110 | 2 14 0.168E-12 111 | 2 15 0.159E-14 112 | 2 16 0.907E-17 113 | 2 17 0.314E-19 114 | 2 18 0.259E-21 115 | 1 0.286E-05 0.750E+00 0.138E+01 116 | 2000. 117 | 10 2 0.31687E-02 118 | 1 1 0.262E-28 119 | 1 2 0.894E-24 120 | 1 3 0.173E-20 121 | 1 4 0.107E-17 122 | 1 5 0.455E-15 123 | 1 6 0.136E-12 124 | 1 7 0.424E-10 125 | 1 8 0.657E-08 126 | 1 9 0.955E-07 127 | 1 10 0.305E-06 128 | 1 11 0.158E-06 129 | 1 12 0.119E-07 130 | 1 13 0.516E-09 131 | 1 14 0.131E-10 132 | 1 15 0.198E-12 133 | 1 16 0.180E-14 134 | 1 17 0.992E-17 135 | 1 18 0.131E-18 136 | 2 1 0.156E-26 137 | 2 2 0.240E-22 138 | 2 3 0.378E-19 139 | 2 4 0.111E-16 140 | 2 5 0.300E-14 141 | 2 6 0.872E-12 142 | 2 7 0.237E-09 143 | 2 8 0.103E-07 144 | 2 9 0.978E-07 145 | 2 10 0.285E-06 146 | 2 11 0.150E-06 147 | 2 12 0.199E-07 148 | 2 13 0.156E-08 149 | 2 14 0.733E-10 150 | 2 15 0.211E-11 151 | 2 16 0.378E-13 152 | 2 17 0.424E-15 153 | 2 18 0.118E-16 154 | 1 0.236E-05 0.636E+00 0.115E+01 155 | 3000. 156 | 5 2 0.37168E-02 157 | 1 1 0.363E-33 158 | 1 2 0.197E-25 159 | 1 3 0.676E-22 160 | 1 4 0.752E-19 161 | 1 5 0.513E-16 162 | 1 6 0.221E-13 163 | 1 7 0.968E-11 164 | 1 8 0.248E-08 165 | 1 9 0.725E-07 166 | 1 10 0.302E-06 167 | 1 11 0.281E-06 168 | 1 12 0.266E-07 169 | 1 13 0.132E-08 170 | 1 14 0.374E-10 171 | 1 15 0.618E-12 172 | 1 16 0.611E-14 173 | 1 17 0.365E-16 174 | 1 18 0.523E-18 175 | 2 1 0.978E-28 176 | 2 2 0.229E-23 177 | 2 3 0.504E-20 178 | 2 4 0.207E-17 179 | 2 5 0.763E-15 180 | 2 6 0.287E-12 181 | 2 7 0.885E-10 182 | 2 8 0.560E-08 183 | 2 9 0.797E-07 184 | 2 10 0.293E-06 185 | 2 11 0.240E-06 186 | 2 12 0.323E-07 187 | 2 13 0.256E-08 188 | 2 14 0.122E-09 189 | 2 15 0.355E-11 190 | 2 16 0.642E-13 191 | 2 17 0.725E-15 192 | 2 18 0.204E-16 193 | 1 0.216E-05 0.591E+00 0.107E+01 194 | 4000. 195 | 3 1 0.38738E-02 196 | 1 1 0.382E-28 197 | 1 2 0.258E-25 198 | 1 3 0.342E-22 199 | 1 4 0.343E-19 200 | 1 5 0.258E-16 201 | 1 6 0.115E-13 202 | 1 7 0.549E-11 203 | 1 8 0.158E-08 204 | 1 9 0.629E-07 205 | 1 10 0.292E-06 206 | 1 11 0.341E-06 207 | 1 12 0.360E-07 208 | 1 13 0.193E-08 209 | 1 14 0.574E-10 210 | 1 15 0.993E-12 211 | 1 16 0.102E-13 212 | 1 17 0.634E-16 213 | 1 18 0.941E-18 214 | 2 1 0.408E-24 215 | 2 2 0.791E-21 216 | 2 3 0.278E-18 217 | 2 4 0.624E-16 218 | 2 5 0.108E-13 219 | 2 6 0.161E-11 220 | 2 7 0.167E-09 221 | 2 8 0.701E-08 222 | 2 9 0.769E-07 223 | 2 10 0.286E-06 224 | 2 11 0.252E-06 225 | 2 12 0.352E-07 226 | 2 13 0.284E-08 227 | 2 14 0.137E-09 228 | 2 15 0.403E-11 229 | 2 16 0.733E-13 230 | 2 17 0.834E-15 231 | 2 18 0.215E-16 232 | 1 0.211E-05 0.579E+00 0.104E+01 233 | 5000. 234 | 2 0 0.40407E-02 235 | 1 1 0.618E-29 236 | 1 2 0.555E-26 237 | 1 3 0.970E-23 238 | 1 4 0.126E-19 239 | 1 5 0.119E-16 240 | 1 6 0.587E-14 241 | 1 7 0.299E-11 242 | 1 8 0.956E-09 243 | 1 9 0.518E-07 244 | 1 10 0.279E-06 245 | 1 11 0.410E-06 246 | 1 12 0.501E-07 247 | 1 13 0.296E-08 248 | 1 14 0.952E-10 249 | 1 15 0.176E-11 250 | 1 16 0.191E-13 251 | 1 17 0.125E-15 252 | 1 18 0.195E-17 253 | 2 1 0.159E-21 254 | 2 2 0.516E-19 255 | 2 3 0.104E-16 256 | 2 4 0.155E-14 257 | 2 5 0.169E-12 258 | 2 6 0.910E-11 259 | 2 7 0.410E-09 260 | 2 8 0.907E-08 261 | 2 9 0.748E-07 262 | 2 10 0.275E-06 263 | 2 11 0.260E-06 264 | 2 12 0.384E-07 265 | 2 13 0.320E-08 266 | 2 14 0.158E-09 267 | 2 15 0.470E-11 268 | 2 16 0.865E-13 269 | 2 17 0.995E-15 270 | 2 18 0.229E-16 271 | 1 0.205E-05 0.565E+00 0.101E+01 272 | -------------------------------------------------------------------------------- /tests/nc_types_mod.F90: -------------------------------------------------------------------------------- 1 | module nc_types_mod 2 | implicit none 3 | 4 | ! All variables and procedures are private except those explicitly declared to be public. 5 | private 6 | public nctype_create 7 | public nc_type 8 | 9 | type :: ncatm_type 10 | logical :: f_nc_p 11 | logical :: f_nc_t 12 | logical :: f_nc_dt 13 | logical :: f_nc_z 14 | logical :: f_nc_rhoa 15 | logical :: f_nc_rlh 16 | end type ncatm_type 17 | 18 | 19 | type :: ncgas_type 20 | logical :: f_nc_mmr 21 | logical :: f_nc_sl 22 | logical :: f_nc_si 23 | logical :: f_nc_ei 24 | logical :: f_nc_el 25 | logical :: f_nc_wt 26 | end type ncgas_type 27 | 28 | type :: ncgroup_type 29 | logical :: f_nc_r 30 | logical :: f_nc_rmass 31 | logical :: f_nc_vol 32 | logical :: f_nc_dr 33 | logical :: f_nc_dm 34 | logical :: f_nc_rup 35 | logical :: f_nc_rlw 36 | logical :: f_nc_rrat 37 | logical :: f_nc_rprat 38 | logical :: f_nc_arat 39 | logical :: f_nc_df 40 | logical :: f_nc_nmon 41 | 42 | logical :: f_nc_nd 43 | logical :: f_nc_ad 44 | logical :: f_nc_md 45 | logical :: f_nc_re 46 | logical :: f_nc_rew 47 | logical :: f_nc_rm 48 | logical :: f_nc_jn 49 | logical :: f_nc_mr 50 | logical :: f_nc_pa 51 | logical :: f_nc_ar 52 | logical :: f_nc_vm 53 | logical :: f_nc_odvis 54 | logical :: f_nc_exvis 55 | 56 | logical :: f_nc_wr_bin 57 | logical :: f_nc_nd_bin 58 | logical :: f_nc_ro_bin 59 | logical :: f_nc_mr_bin 60 | logical :: f_nc_vd_bin 61 | end type ncgroup_type 62 | 63 | type :: ncelem_type 64 | logical :: f_nc_mr_elm_bin 65 | end type ncelem_type 66 | 67 | type :: nc_type 68 | type(ncatm_type), allocatable :: f_nc_atm 69 | type(ncgas_type), allocatable, dimension(:) :: f_nc_gas 70 | type(ncelem_type), allocatable, dimension(:) :: f_nc_elem 71 | type(ncgroup_type), allocatable, dimension(:) :: f_nc_group 72 | 73 | contains 74 | procedure :: nctype_create 75 | 76 | end type nc_type 77 | 78 | 79 | contains 80 | subroutine nctype_create(ncflgs,NGAS, NELEM, NGROUP) 81 | class(nc_type), intent(out) :: ncflgs 82 | integer, intent(in) :: NGAS 83 | integer, intent(in) :: NELEM 84 | integer, intent(in) :: NGROUP 85 | 86 | integer :: igas, ielem, igroup 87 | 88 | ! Allocate tables 89 | allocate( & 90 | ncflgs%f_nc_atm, & 91 | ncflgs%f_nc_gas(NGAS), & 92 | ncflgs%f_nc_elem(NELEM), & 93 | ncflgs%f_nc_group(NGROUP) & 94 | ) 95 | 96 | ! Atm flags 97 | ncflgs%f_nc_atm%f_nc_p = .FALSE. 98 | ncflgs%f_nc_atm%f_nc_t = .FALSE. 99 | ncflgs%f_nc_atm%f_nc_dt = .FALSE. 100 | ncflgs%f_nc_atm%f_nc_z = .FALSE. 101 | ncflgs%f_nc_atm%f_nc_rhoa = .FALSE. 102 | ncflgs%f_nc_atm%f_nc_rlh = .FALSE. 103 | 104 | 105 | ! GAS flags 106 | if (NGAS > 0) then 107 | do igas = 1, NGAS 108 | ncflgs%f_nc_gas(igas)%f_nc_mmr = .FALSE. 109 | ncflgs%f_nc_gas(igas)%f_nc_sl = .FALSE. 110 | ncflgs%f_nc_gas(igas)%f_nc_si = .FALSE. 111 | ncflgs%f_nc_gas(igas)%f_nc_ei = .FALSE. 112 | ncflgs%f_nc_gas(igas)%f_nc_el = .FALSE. 113 | ncflgs%f_nc_gas(igas)%f_nc_wt = .FALSE. 114 | end do 115 | end if 116 | 117 | ! GROUP flags 118 | if (NGROUP > 0) then 119 | do igroup = 1, NGROUP 120 | ncflgs%f_nc_group(igroup)%f_nc_r = .FALSE. 121 | ncflgs%f_nc_group(igroup)%f_nc_rmass = .FALSE. 122 | ncflgs%f_nc_group(igroup)%f_nc_vol = .FALSE. 123 | ncflgs%f_nc_group(igroup)%f_nc_dr = .FALSE. 124 | ncflgs%f_nc_group(igroup)%f_nc_dm = .FALSE. 125 | ncflgs%f_nc_group(igroup)%f_nc_rup = .FALSE. 126 | ncflgs%f_nc_group(igroup)%f_nc_rlw = .FALSE. 127 | ncflgs%f_nc_group(igroup)%f_nc_rrat = .FALSE. 128 | ncflgs%f_nc_group(igroup)%f_nc_rprat = .FALSE. 129 | ncflgs%f_nc_group(igroup)%f_nc_arat = .FALSE. 130 | ncflgs%f_nc_group(igroup)%f_nc_df = .FALSE. 131 | ncflgs%f_nc_group(igroup)%f_nc_nmon = .FALSE. 132 | 133 | ncflgs%f_nc_group(igroup)%f_nc_nd = .FALSE. 134 | ncflgs%f_nc_group(igroup)%f_nc_ad = .FALSE. 135 | ncflgs%f_nc_group(igroup)%f_nc_md = .FALSE. 136 | ncflgs%f_nc_group(igroup)%f_nc_re = .FALSE. 137 | ncflgs%f_nc_group(igroup)%f_nc_rew = .FALSE. 138 | ncflgs%f_nc_group(igroup)%f_nc_rm = .FALSE. 139 | ncflgs%f_nc_group(igroup)%f_nc_jn = .FALSE. 140 | ncflgs%f_nc_group(igroup)%f_nc_mr = .FALSE. 141 | ncflgs%f_nc_group(igroup)%f_nc_pa = .FALSE. 142 | ncflgs%f_nc_group(igroup)%f_nc_ar = .FALSE. 143 | ncflgs%f_nc_group(igroup)%f_nc_vm = .FALSE. 144 | ncflgs%f_nc_group(igroup)%f_nc_exvis = .FALSE. 145 | ncflgs%f_nc_group(igroup)%f_nc_odvis = .FALSE. 146 | 147 | ncflgs%f_nc_group(igroup)%f_nc_wr_bin = .FALSE. 148 | ncflgs%f_nc_group(igroup)%f_nc_nd_bin = .FALSE. 149 | ncflgs%f_nc_group(igroup)%f_nc_ro_bin = .FALSE. 150 | ncflgs%f_nc_group(igroup)%f_nc_mr_bin = .FALSE. 151 | ncflgs%f_nc_group(igroup)%f_nc_vd_bin = .FALSE. 152 | end do 153 | end if 154 | 155 | if (NELEM > 0) then 156 | do ielem = 1, NELEM 157 | ncflgs%f_nc_elem(ielem)%f_nc_mr_elm_bin = .FALSE. 158 | end do 159 | end if 160 | end subroutine nctype_create 161 | 162 | end module nc_types_mod 163 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | # Sub makefile for test files 2 | 3 | # This is intended to be included by another makefile to actually 4 | # build the system. It has all the dependency information for the 5 | # files in the test tree. 6 | 7 | # NOTE: In the future (or in parnet models) this could be replaced 8 | # by automatic dependency generation. 9 | 10 | TEST_OBJ = carma_bcoctest.o carma_bc2gtest.o carma_coagtest.o carma_drydeptest.o carma_falltest.o \ 11 | carma_growtest.o carma_inittest.o carma_kappawetrtest.o carma_mietest.o carma_nuctest.o \ 12 | carma_pheattest.o carma_sigmadrydeptest.o carma_sigmafalltest.o carma_swelltest.o \ 13 | carma_vdiftest.o carma_test.o atmosphere_mod.o carma_scfalltest.o carma_growsubtest.o \ 14 | carma_growintest.o carma_fractalmicrotest.o carma_fractalopticstest.o carma_sulfhettest.o \ 15 | carma_sulfate_vehkamaki_test.o carma_sulfhet_vehkamaki_test.o \ 16 | carma_sulfatetest.o carma_sulfate_ccdon_test.o \ 17 | carma_sulfate_2nc_test.o carma_fractaloptics_2nc_test.o carma_aluminum_2nc_test.o 18 | 19 | TEST_DOC = carma_bcoctest.html carma_bc2gtest.html carma_coagtest.html carma_drydeptest.html \ 20 | carma_falltest.html carma_growtest.html carma_inittest.html carma_kappawetrtest.html \ 21 | carma_mietest.html carma_nuctest.html \ 22 | carma_pheattest.html carma_sigmadrydeptest.html carma_sigmafalltest.html carma_swelltest.html \ 23 | carma_vdiftest.html carma_test.html atmosphere_mod.html carma_scfalltest.html carma_growsubtest.html \ 24 | carma_growintest.html carma_fractalmicrotest.html carma_fractalopticstest.html carma_sulfhettest.html \ 25 | carma_sulfate_vehkamaki_test.html carma_sulfhet_vehkamaki_test.html \ 26 | carma_sulfatetest.html carma_sulfate_ccdon_test.html \ 27 | carma_sulfate_2nc_test.html carma_fractaloptics_2nc_test.html carma_aluminum_2nc_test.html 28 | 29 | atmosphere_mod.o : atmosphere_mod.F90 30 | $(FORTRAN) $(FFLAGS) -c $< 31 | 32 | carma_testutils.o : carma_testutils.F90 33 | $(FORTRAN) $(FFLAGS) -c $< 34 | 35 | ncio_mod.o : ncio_mod.F90 36 | $(FORTRAN) $(FFLAGS) -c $< 37 | 38 | nc_types_mod.o : nc_types_mod.F90 39 | $(FORTRAN) $(FFLAGS) -c $< 40 | 41 | test2nc_mod.o : test2nc_mod.F90 ncio_mod.mod nc_types_mod.mod 42 | $(FORTRAN) $(FFLAGS) -c $< 43 | 44 | carmadiags_mod.o : carmadiags_mod.F90 ncio_mod.mod 45 | $(FORTRAN) $(FFLAGS) -c $< 46 | 47 | carma_bcoctest.o : carma_bcoctest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 48 | $(FORTRAN) $(FFLAGS) -c $< 49 | 50 | carma_bc2gtest.o : carma_bc2gtest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 51 | $(FORTRAN) $(FFLAGS) -c $< 52 | 53 | carma_cetest.o : carma_cetest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 54 | $(FORTRAN) $(FFLAGS) -c $< 55 | 56 | carma_coagtest.o : carma_coagtest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 57 | $(FORTRAN) $(FFLAGS) -c $< 58 | 59 | carma_drydeptest.o : carma_drydeptest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 60 | $(FORTRAN) $(FFLAGS) -c $< 61 | 62 | carma_falltest.o : carma_falltest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 63 | $(FORTRAN) $(FFLAGS) -c $< 64 | 65 | carma_fractalmicrotest.o : carma_fractalmicrotest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 66 | $(FORTRAN) $(FFLAGS) -c $< 67 | 68 | carma_fractalopticstest.o : carma_fractalopticstest.F90 carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 69 | $(FORTRAN) $(FFLAGS) -c $< 70 | 71 | carma_growtest.o : carma_growtest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 72 | $(FORTRAN) $(FFLAGS) -c $< 73 | 74 | carma_growclrtest.o : carma_growclrtest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 75 | $(FORTRAN) $(FFLAGS) -c $< 76 | 77 | carma_growintest.o : carma_growintest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 78 | $(FORTRAN) $(FFLAGS) -c $< 79 | 80 | carma_growsubtest.o : carma_growsubtest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 81 | $(FORTRAN) $(FFLAGS) -c $< 82 | 83 | carma_inittest.o : carma_inittest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 84 | $(FORTRAN) $(FFLAGS) -c $< 85 | 86 | carma_kappawetrtest.o : carma_kappawetrtest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 87 | $(FORTRAN) $(FFLAGS) -c $< 88 | 89 | carma_mietest.o : carma_mietest.F90 carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 90 | $(FORTRAN) $(FFLAGS) -c $< 91 | 92 | carma_nuctest.o : carma_nuctest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 93 | $(FORTRAN) $(FFLAGS) -c $< 94 | 95 | carma_nuc2test.o : carma_nuc2test.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 96 | $(FORTRAN) $(FFLAGS) -c $< 97 | 98 | carma_pheattest.o : carma_pheattest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 99 | $(FORTRAN) $(FFLAGS) -c $< 100 | 101 | carma_scfalltest.o : carma_scfalltest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 102 | $(FORTRAN) $(FFLAGS) -c $< 103 | 104 | carma_sigmadrydeptest.o : carma_sigmadrydeptest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 105 | $(FORTRAN) $(FFLAGS) -c $< 106 | 107 | carma_sigmafalltest.o : carma_sigmafalltest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 108 | $(FORTRAN) $(FFLAGS) -c $< 109 | 110 | carma_swelltest.o : carma_swelltest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 111 | $(FORTRAN) $(FFLAGS) -c $< 112 | 113 | carma_sulfatetest.o : carma_sulfatetest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 114 | $(FORTRAN) $(FFLAGS) -c $< 115 | 116 | carma_sulfhettest.o : carma_sulfhettest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 117 | $(FORTRAN) $(FFLAGS) -c $< 118 | 119 | carma_sulfate_vehkamaki_test.o : carma_sulfate_vehkamaki_test.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 120 | $(FORTRAN) $(FFLAGS) -c $< 121 | 122 | carma_sulfhet_vehkamaki_test.o : carma_sulfhet_vehkamaki_test.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 123 | $(FORTRAN) $(FFLAGS) -c $< 124 | 125 | carma_sulfate_ccdon_test.o : carma_sulfate_ccdon_test.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 126 | $(FORTRAN) $(FFLAGS) -c $< 127 | 128 | carma_test.o : carma_test.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 129 | $(FORTRAN) $(FFLAGS) -c $< 130 | 131 | carma_vdiftest.o : carma_vdiftest.F90 atmosphere_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 132 | $(FORTRAN) $(FFLAGS) -c $< 133 | 134 | carma_sulfate_2nc_test.o : carma_sulfate_2nc_test.F90 atmosphere_mod.mod ncio_mod.mod test2nc_mod.mod carmadiags_mod.mod nc_types_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 135 | $(FORTRAN) $(FFLAGS) -c $< 136 | 137 | carma_fractaloptics_2nc_test.o : carma_fractaloptics_2nc_test.F90 carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod ncio_mod.mod test2nc_mod.mod nc_types_mod.mod 138 | $(FORTRAN) $(FFLAGS) -c $< 139 | 140 | carma_aluminum_2nc_test.o : carma_aluminum_2nc_test.F90 atmosphere_mod.mod ncio_mod.mod test2nc_mod.mod carmadiags_mod.mod nc_types_mod.mod carma_mod.mod carma_constants_mod.mod carma_precision_mod.mod 141 | $(FORTRAN) $(FFLAGS) -c $< 142 | --------------------------------------------------------------------------------