Command file with card system in Fortran90

Last update on May 22, 2009 09:35 AM by jak58
Published by jak58

Command file with card system in Fortran90








I. Introduction


Fortran is a general-purpose programming language that is especially used for numeric computation and scientific computing.


In a code, when digital data need to be modified to run multiple simulations, rather than writing data in the "hard" way in the code, modify and recompile

the code at each simulation, the usual method is to go through a command file which is read by the code during execution.
However, the digital data written to the file must be written in the same order and, furthermore, for a large number of variables change, it can sometimes

be difficult to navigate.

Here is a method that is to go from a command file to a card systen that can be modified as well as comments.
II. Example of command file

Here is a sample command file that we wish to establish suppose that our program deals with population data:

#INHABITANT
295012
#CHILDREN
1098


We'd like to organize data in whatever order you want (possibly the number of children before the total population) and possibly add cards that could be

commented with any character (in the following example only the last card INHABITANT not commented on by! will be displayed).
For example:

#CHILDREN
1567
!#INHABITANT
124590
!#INHABITANT
290745
#INHABITANT
104968



III. Function to search the map you want

Here is the function to read the cards and select one that interests us:

FUNCTION SEARCH_CARD(CARD_SEARCHED,INFO)

    IMPLICIT NONE
    CHARACTER*(*), INTENT(IN) ::  CARD_SEARCHED
    INTEGER, INTENT(OUT) :: INFO
    !! LOCALs !!
    CHARACTER*100 :: CARd

    REWIND(66)

    DO
       READ(66,210,ERR=200,END=200) CARD
       IF(CARD(1:1).EQ.'#') THEN
          CARD = CARTE(2:100)  
          IF(TRIM(CARD).EQ.TRIM(CARD_SEARCHED)) THEN
             INFO=0
             RETURN
          END IF
       END IF
    END DO
200 CONTINUE
    INFO=-1
210 FORMAT(A100)
    RETURN
END FUNCTION SEARCH_CARD



IV. Function to read the CARD you want

The previous function returns INFO =- 1 if the card is not found and INFO = 0 if the CARD is found.
To read the number of inhabitants, for example, simply run the following function:

FUNCTION READ_NUMBER_INHABITANTS (NUMBER_INHABITANTS)
     INTEGER, INTENT (OUT):: NUMBER_INHABITANTS
     ! LOCAL!
     CHARACTER * (*):: CARD
     INTEGER:: INFO

CARD = 'INHABITANTS'
CALL SEARCH_CARD (MAP, INFO)

IF (INFO.EQ.0) THEN
        READ (66, *, ERR = 123, END = 123) NUMBER_INHABITANTS
ELSE
        WRITE (*,*) 'map', TRIM (CARD), 'n'' has not been found, you must'
        WRITE (*,*) ''include in the batch file. "
        STOP
END IF
RETURN
123 CONTINUE
     WRITE (*,*) 'Error reading the number of'habitants on the map'
     WRITE (*,*) TRIM (MAP), 'file commands. "
     STOP
END FUNCTION LIRE_NOMBRE_HABITANTS



Source:

These codings a re based upon the codes written by Francis Collino, CERFACS.


This method is based on Fortran code by Francis Collino, CERFACS.
Best answers for « Command file with card system in Fortran90 » in :
FTP protocol (File Transfer Protocol) Show Introduction to FTP protocol FTP protocol (File Transfer Protocol) is, as its name indicates a protocol for transferring files. The implementation of FTP dates from 1971 when a file transfer system (described in RFC141) between MIT machines...
Recovering lost files ShowRecovering lost files Summary Preconditions Under Windows Freeware PC Inspector File Recovery Restoration Hand Recovery Undelete Plus SoftPerfect File Recovery Photorec&Testdisk Instruction for application Notice Under...
Command prompts for Windows ShowCommand prompts for Windows Some of these command below can cause harmful an undesirable functions, leading to the formatting of your hard disk and data loss, while others will not run under Windows XP. As for Windows Vista the Run Tab is not...
Keyboard Shortcuts for Windows ShowKeyboard Shortcuts for Windows Windows System In a General Folder and text programs In a General Folder For a Selected Item a Folder For Microsoft Word For Microsoft Excel For Microsoft PowerPoint For Internet Explorer There are a...
Download Ext2 Installable File System ShowIf you currently have Windows running and you realize that you need some files for your work which you have stored on an Ext2 volume of your Linux installation, you no longer have to shut down Windows and boot Linux! Furthermore, Windows will now...
UNIX system - The shell ShowIntroduction to the shell The command interpreter is the interface between the user and the operating system, hence its name "shell". The shell therefore acts as an intermediary between the operating system and the user using command lines...
The NTFS file system ShowThe NTFS file system The NTFS file system (New Technology File System) is based on a structure called the "master file table" or MFT, which is able to hold detailed information on files. This system allows the use of long names, but, unlike the...
UNIX Commands ShowTable of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...