From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16688 invoked by alias); 1 Feb 2011 10:23:26 -0000 Received: (qmail 16679 invoked by uid 22791); 1 Feb 2011 10:23:25 -0000 X-SWARE-Spam-Status: No, hits=1.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cavuit01.kulnet.kuleuven.be (HELO cavuit01.kulnet.kuleuven.be) (134.58.240.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Feb 2011 10:23:06 +0000 Received: from smtps02.kuleuven.be (smtpshost02.kulnet.kuleuven.be [134.58.240.75]) by cavuit01.kulnet.kuleuven.be (Postfix) with ESMTP id 263457B805E for ; Tue, 1 Feb 2011 11:23:00 +0100 (CET) Received: from [192.168.2.6] (ip545076c1.speed.planet.nl [84.80.118.193]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtps02.kuleuven.be (Postfix) with ESMTP id C115DF3862 for ; Tue, 1 Feb 2011 11:22:59 +0100 (CET) Message-ID: <4D47DF02.8060903@ees.kuleuven.be> Date: Tue, 01 Feb 2011 10:23:00 -0000 X-Kuleuven: This mail passed the K.U.Leuven mailcluster From: Matthias Demuzere User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: System call under Linux, gfortran v4.4.5 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-KULeuven-Information: Katholieke Universiteit Leuven X-KULeuven-Scanned: Found to be clean X-KULeuven-Envelope-From: matthias.demuzere@ees.kuleuven.be X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00004.txt.bz2 Hi All, I am building a model which should be portable to any possible platform. Unfortunately, the support for gfortran users is limited, so that is why I try to ask my question here. There is a script that used the system() command. Now, as a (g)fortran newbie, I am not exactly sure what it does, and definitely not how to define it for my linux environment. In my example: public :: shr_sys_system ! make a system call public :: shr_sys_chdir ! change current working dir public :: shr_sys_getenv ! get an environment variable public :: shr_sys_abort ! abort a program public :: shr_sys_irtc ! returns real-time clock tick public :: shr_sys_sleep ! have program sleep for a while public :: shr_sys_flush ! flush an i/o buffer in which a subroutine is configured as follows (e.g. for shr_sys_system): SUBROUTINE shr_sys_system(str,rcode) IMPLICIT none !----- arguments --- character(*) ,intent(in) :: str ! system/shell command string integer(SHR_KIND_IN),intent(out) :: rcode ! function return error code !----- functions ----- #if (defined CRAY) || (defined UNICOSMP) integer(SHR_KIND_IN),external :: ishell ! function to envoke shell command #endif #if (defined OSF1 || defined SUNOS || (defined LINUX && !defined __G95__) || (defined LINUX && !defined CATAMOUNT)) integer(SHR_KIND_IN),external :: system ! function to envoke shell command #endif !----- local ----- #if (defined CATAMOUNT) character(2*SHR_KIND_CL) :: file1 ! one or two filenames character( SHR_KIND_CL) :: file2 ! 2nd file name integer(SHR_KIND_IN) :: iloc ! index/location within a string #endif !----- formats ----- character(*),parameter :: subName = '(shr_sys_system) ' character(*),parameter :: F00 = "('(shr_sys_system) ',4a)" !------------------------------------------------------------------------------- ! PURPOSE: an architecture independant system call ! NOTE: ! - for Catamount (Cray, pheonix at ORNL) there is no system call -- workarounds ! exist only for simple "rm" and "cp" commands !------------------------------------------------------------------------------- In the last part, there are some calls dependent on my system (my case = Linux): #if (defined CRAY) || (defined UNICOSMP) rcode=ishell(str) #endif #if (defined IRIX64 || defined NEC_SX) rcode = 0 call system(str) #endif #if (defined AIX) call system(str,rcode) #endif #if (defined OSF1 || defined SUNOS || defined LINUX && !defined CATAMOUNT || defined __G95__) rcode = SYSTEM(str) #endif #if (!defined CRAY && !defined IRIX64 && !defined AIX && !defined OSF1 && !defined SUNOS && !defined LINUX && !defined NEC_SX && !defined UNICOSMP && !defined __G95__) write(s_logunit,F00) 'ERROR: no implementation for this architecture' call shr_sys_abort(subName//'no implementation for this architecture') #endif END SUBROUTINE shr_sys_system So my question here is how to define the system call exactly for Linux. Because as it is now, I get the following error: /usr/workdir/cesm1_0_2/scripts/test2/lib/libcsm_share.a(shr_sys_mod.o): In function `shr_sys_system': /usr/workdir/cesm1_0_2/models/csm_share/shr/shr_sys_mod.F90:83: undefined reference to `system_' and I can't seem to find a lot of information on this on the web! Therefore, any help is welcome! Cheers, Matthias