This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Trung, re: > I have the following line of code in a *.mac file. > > CALL SYSTEM('/home/dpis/mcidas/data/emailnote '//CSTAT) > > I would like to define an $ANCHOR with the above path value - > $ANCHOR=/home/dpis/mcidas/data and would like to have that $ANCHOR in > the CALL SYSTEM command. > > i.e. CALL SYSTEM('$ANCHOR/emailnote '//CSTAT) so the $ANCHOR will be > replaced by '/home/dpis/mcidas/data' at run time. > > How would I do that in Fortran? Not sure of what the syntax is. Thanks. Since expansion of references to environment variable (e.g., $ANCHOR) is done by the shell, I don't think that you will be able to do what you want to do in one step. Instead, you will need to: - call the Fortran library routine 'getenv' to get the value of your 'anchor' variable (environment variable) - run the comand using the library routine 'system' Here is some code that should approximate this: character*80 anchor integer len_trim integer length ... call getenv('ANCHOR', anchor) length = len_trim(anchor) call system(anchor(1:length)//'emailnote '//CSTAT) Cheers, Tom **************************************************************************** Unidata User Support UCAR Unidata Program (303) 497-8642 P.O. Box 3000 address@hidden Boulder, CO 80307 ---------------------------------------------------------------------------- Unidata HomePage http://www.unidata.ucar.edu **************************************************************************** Ticket Details =================== Ticket ID: UGB-430567 Department: Support McIDAS Priority: Normal Status: Closed