PROGRAM LATLON !!*********************************************************************** !! Version "$Id: latlon.F 1703 2014-12-17 21:39:36Z coats@bdsl$" !! EDSS/Models-3 M3TOOLS. !! Copyright (C) 1992-2002 MCNC, (C) 1997-2017 Carlie J. Coats, Jr., !! (C) 2002-2012 Baron Advanced Meteorological Systems. LLC., and !! (C) 2014-2015 UNC Institute for the Environment. !! Distributed under the GNU GENERAL PUBLIC LICENSE version 2 !! See file "GPL.txt" for conditions of use. !!......................................................................... !! program body starts at line 77 !! subroutine MAKEGRD starts at line 343 !! subroutine MAKEBDY starts at line 405 !! !! DESCRIPTION: !! Builds 1-layer time-independent gridded file with LAT and LON !! !! PRECONDITIONS REQUIRED: !! "setenv"s for output files, GRIDDESC file !! "f77 latlon.F -o latlon -L/home/xcc/SunOS5 -lemstuff -lm3io -lnetcdf" !! from a directory containing PARMS3.EXT, FDESC3.EXT, IODECL3.EXT !! !! SUBROUTINES AND FUNCTIONS CALLED: !! I/O API and utility routines; Lambert conversion routines from !! libemstuff !! !! REVISION HISTORY: !! prototype 7/96 by CJC !! Modified 9/99 by CJC for enhanced portability !! Modified 9/99 by CJC: more internal documentation about !! I/O API grid concepts. !! Version 11/2001 by CJC for I/O API Version 2.1 !! Version 11/2005 by CJC: eliminate unused vbles !! Version 11/2007 by CJC: splash-screen/contact-info update !! Version 06/2008 by CJC: Changes for Albers conformal conic !! !! Version 02/2010 by CJC for I/O API v3.1: Fortran-90 only; !! USE M3UTILIO, and related changes. !! Version 12/2013 by CJC: PARAMETER CMENU(:), CTYPE(:) !! Version 02/2015 by CJC for I/O API-v3.2: USE MODGCTP; !! Fortran-90 "free" source format; use generics for "GET*()" !! Version 12/2017 by CJC; add double-precision vbles LATD, LOND; !! add/fix EQMGRD3, TRMGRD3, MERGRD3, POLGRD3, STEGRD3, LEQGRD3 support. !!*********************************************************************** USE M3UTILIO USE MODGCTP IMPLICIT NONE !!........... PARAMETERS and their descriptions: CHARACTER*16, PARAMETER :: NONE = 'NONE' CHARACTER*16, PARAMETER :: PNAME = 'LATLON' CHARACTER*20, PARAMETER :: CMENU( 10 ) = & (/ 'lat-lon (ISO 6709) ', & ! coordinate types menu item 1 'Lambert Conformal ', & ! coordinate types menu item 2 'Lambert Equal Area ', & ! coordinate types menu item 3 'Equatorial Mercator ', & ! coordinate types menu item 4 'Transverse Mercator ', & ! coordinate types menu item 5 'General Mercator ', & ! coordinate types menu item 6 'Polar Stereographic ', & ! coordinate types menu item 7 'General Stereographic', & ! coordinate types menu item 8 'UTM ', & ! coordinate types menu item 9 'Albers Equal-Area ' /) ! coordinate types menu item 10 INTEGER, PARAMETER :: CTYPE( 10 ) = & (/ LATGRD3, LAMGRD3, LEQGRD3, EQMGRD3, TRMGRD3, MERGRD3, POLGRD3, STEGRD3, UTMGRD3, ALBGRD3 /) !!........... LOCAL VARIABLES and their descriptions: INTEGER L INTEGER LOGDEV CHARACTER*16 ANAME, BNAME, GNAME CHARACTER*160 MESG !!*********************************************************************** !!....... First: Initialize the I/O API: LOGDEV = INIT3() ! initialization returns unit # for log WRITE( *, '( 5X, A )' ) ' ', & 'Program LATLON to construct matching TIME-INDEPENDENT 1-LAYER GRIDDED', & 'and BOUNDARY TIME-INDEPENDENT I/O API files containing the latitude and', & 'longitude at cell centers, for a user specified coordinate system and', & 'grid. You may turn off either file (GRIDDED or BOUNDARY) by responding', & '"NONE" to the prompt for its name.', & '', & 'Specifications for this grid may either come from a GRIDDESC file', & '(if it has a named grid), or may be entered interactively.', & '', & 'NOTE: Currently, only Lat-lon, Lambert, UTM, Equatorial or Transverse', & 'Mercator, Polar Stereographic and Albers Equal-Area coordinate systems,', & 'and boundaries with NTHIK > 0 are supported interactively.', & '', & 'You will be prompted for the logical name of the output files.', & 'You will need to have set up the environment for this program ', & 'by appropriate commands ', & '', & ' setenv "', & '', & 'for the output files and (if you use it) the GRIDDESC file.', & '', & 'See URL', & 'https://www.cmascenter.org/ioapi/documentation/3.1/html#tools', & '', & 'Program copyright (C) 1992-2002 MCNC, (C) 1995-2017 Carlie J. Coats, Jr.', & '(C) 2002-2010 Baron Advanced Meteorological Systems, LLC., and', & '(C) 2015 UNC Institute for the Environment.', & 'Released under Version 2 of the GNU General Public License. See', & 'enclosed GPL.txt, or URL', & '' , & ' https://www.gnu.org/licenses/old-licenses/gpl-2.0.html', & '' , & 'Comments and questions are welcome and can be sent to' , & '', & ' Carlie J. Coats, Jr. carlie@jyarborough.com', & 'or', & ' UNC Institute for the Environment', & ' 100 Europa Dr., Suite 490 Rm 405', & ' Campus Box 1105', & ' Chapel Hill, NC 27599-1105', & '', & 'Program version: ', & '$Id: LATLON.txt 74 2017-12-22 19:40:11Z coats $',& '' IF ( .NOT. GETVAL( 'Continue with program?', .TRUE. ) ) THEN CALL M3EXIT( PNAME, 0, 0, 'Program ended at user request', 0 ) END IF MESG = 'Enter logical name for GRIDDED output file, or "NONE"' CALL GETSTR( MESG, 'GRDFILE', GNAME ) MESG = 'Enter logical name for BOUNDARY output file, or "NONE"' CALL GETSTR( MESG, 'BDYFILE', BNAME ) IF ( GNAME .EQ. NONE .AND. BNAME .EQ. NONE ) THEN CALL M3EXIT( PNAME, 0, 0, 'No output files requested', 2 ) END IF !! According to EDSS/Models-3 I/O API coordinate and grid !! conventions, the basic idea is: !! !! One defines a horizontal Cartesian coordinate system !! ("map projection") as giving (X,Y) coordinates (generally !! in MKS units, i.e. Meters) relative to some known origin !! (XCENT,YCENT), in terms of some known defining angles !! (P_ALP, P_BET, P_GAM). !! !! Having defined a map projection, one than then define !! horizontal grids within it by specifying: !! !! The (1,1)-corner (XORIG, YORIG) in terms of the !! Cartesian coordinates of the map projection !! (note that for the specification of this corner, !! we take a "grid-cells are volumes" approach rather !! than a Poincare-dual "grid is array of node-points" !! point of view); !! !! The cellsize (XCELL, YCELL) in both coordinate !! directions; !! !! The dimensionality (NCOLS,NROWS). !! !! (Optionally) the thickness NTHIK in cells of a !! boundary data-structure for the grid. !! !! Note that frequently, we expect to have multiple grids !! with the same map projection. !! !! Having defined a grid in terms of a (MKS-unit) Cartesian !! coordinate system mapped from the surface of the Earth, !! one can then transform grid-related problems into problems !! stated in (non-metric) grid-normal coordinates defined !! relative to the (1,1) corner of the grid, as given by the !! formulas !! !! REAL C,R !! ... !! C = (X - XORIG) / XCELL !! R = (Y - YORIG) / YCELL !! !! for which the (I,J) cell is {(C,R): I-1 <= C