; $Id: gamap_init.pro,v 1.23 1999/03/23 18:00:51 mgs Exp $ ;------------------------------------------------------------- ;+ ; NAME: ; GAMAP_INIT ; ; PURPOSE: ; Initialize global common block for Global Atmospheric ; Model output Analysis Package (GAMAP). This routine is ; automatically called when gamap_cmn.pro is included in a ; file ( @gamap_cmn.pro ), but it executes only once. ; User preferences are read from the file gamap.defaults ; in the current directory or the directory where ; gamap_init.pro resides. ; ; CATEGORY: ; CTM routines ; ; CALLING SEQUENCE: ; GAMAP_INIT ; ; INPUTS: ; none ; ; KEYWORD PARAMETERS: ; DEBUG -> set a (new) debug level (0 or 1). ; ; OUTPUTS: ; none ; ; SUBROUTINES: ; ; REQUIREMENTS: ; This routine uses FILE_EXIST, EXTRACT_PATH, ; and OPEN_FILE ; ; NOTES: ; If you change the definition o fthe common block ; in gamap_cmn.pro, make sure to accomodate these changes ; in GAMAP_INIT. ; ; EXAMPLE: ; ; MODIFICATION HISTORY: ; mgs, 14 Aug 1998: VERSION 1.00 ; mgs, 21 Sep 1998: - changed gamap.cmn to gamap_cmn.pro ; mgs, 05 Oct 1998: - type assignment fix to DEBUG when read ; mgs, 08 Oct 1998: - now runs through after CTM_CLEANUP and does ; not delete global pointers if valid. ; - added DEBUG keyword ; mgs, 21 Jan 1999: - added postscript options ; bmy, 19 Feb 1999: - added GIF_FILENAME ; bmy, 22 Feb 1999: VERSION 1.01 ; - added more animation options ; - changed POSTSCRIPT to DO_POSTSCRIPT ; - default path now amalthea ; mgs, 23 Mar 1999: - slight change in defaults ; ;- ; Copyright (C) 1998, Martin Schultz, Harvard University ; This software is provided as is without any warranty ; whatsoever. It may be freely used, copied or distributed ; for non-commercial purposes. This copyright notice must be ; kept with any copy of this software. If this software shall ; be used commercially or sold as part of a larger package, ; please contact the author to arrange payment. ; Bugs and comments should be directed to mgs@io.harvard.edu ; with subject "IDL routine gamap_init" ;------------------------------------------------------------- pro gamap_init,debug=newdebug @gamap_cmn.pro ; include global common block definition on_error,2 ; new default debug value (-1 will leave unchanged) if (n_elements(newdebug) eq 0) then newdebug = -1 ; return if variables are already defined ; and DEBUG has a valid state (allows redefinitions after cleanup) if (n_elements(DefaultModel) gt 0 AND $ n_elements(DefaultPath) gt 0 AND $ n_elements(pGlobalFileInfo) gt 0 AND $ n_elements(pGlobalDataInfo) gt 0 AND $ n_elements(DEBUG) gt 0) then $ if (DEBUG ge 0) then return ; set default values DefaultModel = 'GEOS1' DefaultPath = '~/amalthea/CTM4/*pch*' CreatePostscript = '*QUERY' AddTimeStamp = '*QUERY' DefaultPSFilename = 'idl.ps' CreateGIF = '*QUERY' DefaultGIFFileName = '*QUERY' CreateMPEG = '0' DefaultMPEGFileName = '*QUERY' CreateAnimation = '0' ; obsolete **** if (not ptr_valid(pGlobalFileInfo)) then pGlobalFileInfo = ptr_new() if (not ptr_valid(pGlobalDataInfo)) then pGlobalDataInfo = ptr_new() Debug = 0 ; try to read file gamap.defaults in local directory ; or directory of this routine if (not file_exist('gamap.defaults',full=full)) then begin ; get filepath of this routine dum = Routine_name( FileName=ProFileName ) if ( File_Exist( ProFileName, path=!PATH, full=full) ) then begin TestName = Extract_Path( Full ) + 'gamap.defaults' if (not File_Exist( TestName, Full=Full)) then return endif endif open_file,full,ilun,/NO_PICKFILE if (ilun lt 0) then $ message,'*** Cannot open gamap.defaults file ! ***' ; read default information from file print,'reading gamap.defaults ...' while (not eof(ilun)) do begin s = '' readf,ilun,s s = strtrim(s,2) if (s eq '') then s = '#' if (strmid(s,0,1) ne '#') then begin ; extract tokens tok = str_sep(s, '=', /TRIM) if (n_elements(tok) ne 2) then begin print,'Syntax error in token definition !' print,s goto,fileread_error endif ;**** added more animation options (bmy, 2/22/99) case (strupcase(tok[0])) of 'MODELNAME' : DefaultModel = tok[1] 'FILEMASK' : DefaultPath = tok[1] 'DO_POSTSCRIPT' : CreatePostscript = strupcase(tok[1]) 'TIMESTAMP' : AddTimeStamp = strupcase(tok[1]) 'PS_FILENAME' : DefaultPSFilename = tok[1] 'DO_GIF' : CreateGIF = tok[1] 'GIF_FILENAME' : DefaultGIFFileName = Tok[1] 'DO_MPEG' : CreateMPEG = tok[1] 'MPEG_FILENAME' : DefaultMPEGFileName = Tok[1] 'DO_ANIMATE' : ; nothing . OLD: CreateAnimation = tok[1] 'DEBUG' : Debug = fix(tok[1]) else : print,'Invalid token : ',tok[0] endcase endif endwhile free_lun,ilun ; set new DEBUG value if (newdebug ge 0) then DEBUG = newdebug return fileread_error: print,'*** Error reading file gamap.defaults : ',!ERR, !ERR_STRING free_lun,ilun return end